-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Answers to Big O Exercises #20
base: master
Are you sure you want to change the base?
Conversation
@@ -70,4 +109,6 @@ function subtotals(array) { | |||
} | |||
return subtotalArray; | |||
} | |||
Time: O(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double-check your time complexity here
@@ -44,6 +79,8 @@ function logAtLeast10(n) { | |||
console.log(i); | |||
} | |||
} | |||
Time: O(n) if n > 10, O(1) if n < 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since big O notation only cares about sufficiently large values of n, it's fine to just say O(n) here.
7. `O(1000 * n * log(n) + n)` | ||
|
||
O(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double check this one.
8. `O(2^n + n^2)` | ||
|
||
O(n^2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double check this one too (i recognize this one is a bit challenging, since we didn't explicitly talk about exponentials vs. quadratics in class)
Here are my Big O answers, Teach(ers)...