Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ggladden
Copy link

Here are my Big O answers, Teach(ers)...

@@ -70,4 +109,6 @@ function subtotals(array) {
}
return subtotalArray;
}
Time: O(n)
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants