Time complexity of linear search
O(n)
Time complexity of binary search
O(log n)
Time complexity of hash table search
Without collision resolution: O(1)
With collision resolution: O(n)
For a hash table, a hash function should:
Returns an output hash index of fixed size
For a hash table, a key should be:
Immutable (so that its hashed location is always the same)
Features of an ideal hash function
The key steps for Binary Search are:
start = 0 and end = array.length - 1midmid:midend to mid - 1start to mid + 1start > end (no match found), return none or display/raise error, else repeat from step 3