What is the order from the best O time complexities to the worst ones?
O(1), O(log n), O(sqrt n), O(n), O(n log n), O(n^2), O(2^n), O(n!)
How does O(1) work?
How does O(n) work?
How does O(log n) work?
How does O(n^2) work?
How do you determine the O value of two independent methods?
O(a + b)
How do you determine the O value of nested loops?
O(a * b)
What are the time complexities of binary search?
Best: O(1)
Other: O(log n)
What are the space complexities for all the sorting/searching methods?
What are the time complexities of bubble sort?
O(n^2) for all
What are the time complexities of optimized bubble sort?
Best: O(n)
Others: O(n^2)
What are the time complexities for selection sort?
O(n^2) for all
What are the time complexities for insertion sort?
Best: O(n)
Others: O(n^2)
What time complexity does String.substring() give?
O(n)
What time complexity does String.indexOf() give?
O(n)
What time complexity does ArrayList.remove(i) give?
O(n)
What time complexity does String.add(i, val) give?
O(n)
What time complexity does String.get(i) give?
O(1)
What time complexity does a nested loop that shrinks give? What can shrink?
O(n^2)
- y can have j < i or j < n
What does binary recursion give off?
O(2^n)
When you include the use of strings in a loop, what is the time complexity given?
O(n^2)
How do insertion and selection sort compare on an array that is mostly sorted?
How do insertion sort, bubble sort, and selection sort compare in space usage?
All are the same