Efficient Sorting
and Searching in Static/Resize-able Array
- O(n2)
comparison-based
sorting algorithms:
Bubble/Selection/Insertion Sort.
- O(n log n)
comparison-based
sorting algorithms:
Merge/Heap/Random Quick Sort
- O(n) special purpose
sorting algorithms:
Radix Sort, Bucket Sort, Counting Sort
- O(n)
Linear Search
from index 0 to index n-1 (avoid this in programming contests)
- O(log n)
Binary Search:
use lower bound in C++ STL <algorithm> (or Java
Collections.binarySearch).
- O(1)
hashing
|