Which search technique the given steps are associated with?
Step 1: SET first = 0, last = n-1
Step 2: Calculate mid = (first+last)//2
Which search technique the given steps are associated with?
Step 1: SET first = 0, last = n-1
Step 2: Calculate mid = (first+last)//2
Solution
Binary search works on a sorted list. It keeps two pointers, first and last, set to the two ends of the list ( and ), and finds the middle index with . The key is compared with the element at mid, and the search then continues in the left or right half. This halves the search range each time.
Linear Search: it checks elements one by one from the start, using an index that moves forward, and never calculates a middle position.
Searching by Hashing: it uses a hash function to compute the position of the key directly, not a midpoint of two bounds.
Collision: this is not a search technique. It is the situation in hashing where two keys map to the same index.
Related questions:
2025: 3 June Shift 2
2026: 11 May Shift 2
2026: 31 May Shift 1
2025: 15 May Shift 2