2.3.1 algorithms Flashcards
what is worst case average case and best case for a linear search
O(n) O(n), O(1)
what is worst case average case and best case for a Binary search
O(log(n)) O(log(n)) O(1)
what is worst case average case and best case for a binary search tree
O(n), O(log(n)), O(1)
what is worst case average case and best case for searching a hash table
O(n) O(1) O(1)
what is worst case average case and best case for a breadth/depth of a graph
O(v^2) O(V+E) O(1)
what is worst case average case and best case for a bubble sort
O(n^2) O(n^2) O(n)
what is worst case average case and best case for a insertion sort
O(n^2) O(n^2) O(n)
what is worst case average case and best case for a Merge sort
O(nlog(n)) O(nlog(n)) O(nlog(n))
what is worst case average case and best case for quick sort
O(n*log(n)) O(nlog(n)) O(n^2)
what is the space complexity of merge sort
O(n) (because it has to make temporary arays with a sieze proportional to the main array)
what is the space complexity of quick sort
O(log(n)) (dont have to know but makes log(n) recursive calls and makes an array of fixed size each recursive call)
what is the space complexity of bubble and insertion sort
O(1)