Big-O-Notation Exercise (Jordan Mittelman) #9

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@triplespice

triplespice commented May 13, 2019

3 comfort

4 completeness

I wasn't able to interpret what some of these functions were doing

@@ -17,6 +17,8 @@ function wordOccurrence(word, phrase) {
}
```

O(log(N)) This is logarithmic complexity.

This comment has been minimized.

@Zakk

Zakk May 13, 2019

Close! There is an N in the complexity

@@ -34,6 +36,8 @@ function bubble_sort(list) {
}
```

O(N^2) this is quadratic complexity because there is a nested loop

This comment has been minimized.

@Zakk
@@ -46,6 +50,8 @@ function factorial(n) {
}
```

O(N) This is linear complexity. It goes one step at a time.

This comment has been minimized.

@Zakk
@@ -54,6 +60,8 @@ function bobIsFirst(people) {
}
```

O(1) This is constant complexity. It is doing one simple thing.

This comment has been minimized.

@Zakk
@@ -70,6 +78,8 @@ function isPalindrome(input) {
}
```

O(N) This is linear complexity. as it iterates through it goes one step at a time.

This comment has been minimized.

@Zakk
@@ -85,6 +95,8 @@ function sumOfDivisors(n) {
}
```

O(N!) This is factorial because it keeps looping.

This comment has been minimized.

@Zakk

Zakk May 13, 2019

Close! There is an N

@@ -100,6 +112,8 @@ function printAllNumbersThenSumPairs(numArray) {
}
```

O(N^2) this is quadratic complexity because there is a function nested within a function

This comment has been minimized.

@Zakk

Zakk May 13, 2019

Close! forEach is a loop

@@ -115,3 +129,5 @@ function isPrime(num) {
return true;
}
```

O(N) This is linear complexity. as it iterates through it goes one step at a time.

This comment has been minimized.

@Zakk
@Zakk

This comment has been minimized.

Zakk commented May 13, 2019

@triplespice Very nice! You have a couple to review but I've marked this as complete

@Zakk Zakk closed this May 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment