Notes · Class 12 · CBSE · Science Computer Science

Searching notes

Revision notes for the chapter: the key points, definitions and exam tips to remember.

Searching finds the position of a key in a collection.

LINEAR (SEQUENTIAL) SEARCH

  • Check each element one by one from the start.
  • Works on unsorted lists.
  • Comparisons: best 1, worst n. Time O(n).

BINARY SEARCH

  • Works only on sorted lists.
  • Compare with the middle element; search the left or right half; repeat.
  • mid = (first + last) // 2.
  • Time O(log n) — much faster for large lists.

SEARCH BY HASHING

  • Hash function maps a key to an index (e.g. key % table size). Ideal search time O(1).
  • Collision: two keys map to the same index; needs resolution.
Memory hook: "Linear walks every step; binary halves the problem."

Searching: practice questionsSearching cheat sheet

More Class 12 · CBSE · Science Computer Science notes

Practise Searching

Sign up free to practise the full chapter after revising. Questions you get wrong come back until you've mastered them.

Start practising free

Free to start · No credit card needed