2.3.4 average time complexities of different searching algorithms Flashcards
1
Q
Linear search
A
O(n)
Worst case is O(n)
Best case is O(1) (finding it instantly)
2
Q
Binary search (array)
A
O(log(n))
Worst case is O(log(n))
Best case is O(1)
3
Q
Binary search (tree)
A
O(log(n))
Worst case is O(n)
Best case is O(1)
4
Q
Hashing
A
O(1)
Worst case is O(n)
Best case is O(1)
5
Q
Breadth/depth first of graph
A
O(V+E) (number of vertices + number of edges)
Worst case is O(V^2) (number of vertices, squared)
Best case is O(1)