Skip to main contentSkip to solution

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

✅ Correct Option: 3

Binary search works on a sorted list. It keeps two pointers, first and last, set to the two ends of the list (00 and n−1n-1), and finds the middle index with mid=(first+last)//2mid = (first + last)//2. 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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question