Skip to content

Instantly share code, notes, and snippets.

View AnasAboreeda's full-sized avatar
📚
learning one thing about everything and learning everything about one thing

Anas Aboreeda AnasAboreeda

📚
learning one thing about everything and learning everything about one thing
View GitHub Profile
### Keybase proof
I hereby claim:
* I am anasaboreeda on github.
* I am aboureada (https://keybase.io/aboureada) on keybase.
* I have a public key ASAHGpIoHJh5EECgSV2kjRYGTj0S7QoX8xjRO3kF29CV_Qo
To claim this, I am signing this object:
class Permutation {
void permutation(String str) {
permutation(str, "");
}
void permutation(String str, String prefix) {
if (str.length() == 0) {
System.out.println(prefix);
} else {
int factorial(int n) {
if (n < 0) {
return -1;
} else if (n
return 1;
} else {
return n * factorial(n - 1);
}
}
int f(int n) {
if (n <= 1) {
return 1;
}
return f(n - 1) + f(n - 1);
}
class NestedLoop {
public static void main(String[] args) {
int n = 10; // O(1)
int sum = 0; // O(1)
int j = 1; // O(1)
double pie = 3.14; // O(1)
for (int var = 0; var < n; var++) { // 0(n)
System.out.println("Pie: " + pie); // 0(n)
while(j < var) { // 0(n)
class NestedLoop {
public static void main(String[] args) {
int n = 10;
int sum = 0;
int j = 1;
double pie = 3.14;
for (int var = 1; var < n; var += 3) { // O(n/3)
System.out.println("Pie: " + pie); // O(n/3)
j = 1; // O(n/3)
class NestedLoop {
public static void main(String[] args) {
int n = 10; // O(time complexity of the called function)
int sum = 0; //O(1)
double pie = 3.14; //O(1)
int var = 1;
while(var < n) { // O(log3 n)
System.out.println("Pie: " + pie); // O(log3 n)
class NestedLoop {
public static void main(String[] args) {
int n = 10; // O(time complexity of the called function)
int sum = 0; //O(1)
double pie = 3.14; //O(1)
int var = 1;
while(var < n) { // O(log n)
System.out.println("Pie: " + pie); // O(log n)
class NestedLoop {
public static void main(String[] args) {
int n = 10; // O(time complexity of the called function)
int sum = 0; //O(1)
double pie = 3.14; //O(1)
for (int var = n; var >= 1; var = var - 3) { // O(n/3)
System.out.println("Pie: " + pie); // O(n/3)
class NestedLoop {
public static void main(String[] args) {
int n = 10; // 1 step --> Note: n can be anything. This is just an example
int sum = 0; // 1 step
double pie = 3.14; // 1 step
for (int var = 0; var < n; var = var + 3) { // n/3 steps
System.out.println("Pie: " + pie); // n/3 steps
for (int j = 0; j < n; j = j + 2) { // (n/3 * n/2) steps
sum++; // (n/3 * n/2) steps