Binary Search
We assume the array elements are sorted, and we want to find if the input value is inside the array using binary search (divide and conquer).
| Array Size | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| Iterations | 0 | 1 | 2 | 2 | 3 | 3 | 3 | 4 |
We notice that the iterations it takes to find out the element in worse case is $O(\log n + 1)$.
1 | |
Recursion
1 | |
Fibonacci Sequence
0, 1, 1, 2, 3, 5, 8, 13, 21, 34…
1 | |
Bubble Sort
| Worst-case complexity | Average-case complexity | Best-case complexity | Space complexity |
| $O(n^2)$ | $O(n^2)$ | $O(n^2)$ | $O(n)$ |
1 | |
Merge Sort
| Worst-case complexity | Average-case complexity | Best-case complexity | Space complexity |
| $O(n \log n)$ | $O(n \log n)$ | $O(n \log n)$ | $O(n)$ |
1 | |
QuickSort
| Worst-case complexity | Average-case complexity | Best-case complexity | Space complexity |
| $O(n^2)$ | $O(n \log n)$ | $O(n \log n)$ | $O(\log n)$ |
1 | |
Reference: Udacity Technical Interview Course