Binary Search

Practise binary search on sorted values, boundaries, rotated arrays, answer ranges, partitions and matrices.

52 online
Overall Progress
PLUS – Videos, editorials, planner all in one place – Videos, editorials, personalised planner & TUFY all in one place to save your time.

Planly

Know more

Striver’s Binary Search Sheet contains 32 coding questions covering lookup, lower and upper bounds, rotations, roots, missing values, searches over possible answers, sorted-array partitions, peaks and matrices. The list includes all 32 practice questions from the corresponding A2Z section. The foundation is explaining which candidate region a comparison can safely discard.

Treat the groups as different uses of search reasoning rather than one loop with different conditions. Exact lookup, first qualifying position and minimum feasible capacity ask for different boundaries. Some variants depend on sorted values, while others depend on a monotonic feasibility condition or a special structural guarantee supplied by the problem.

Topics covered in this practice sheet

The early questions cover direct lookup and boundaries. Rotated arrays and special positions then use structural information rather than ordinary sorted lookup alone. Searches over possible answers require a monotonic feasibility check, while matrix questions depend on the precise ordering guarantees in their statements.

  • Direct lookup, insertion positions, lower/upper bounds and occurrence ranges.
  • Rotated arrays, special positions, roots and missing values.
  • Search on answers, partitions and matrix applications.

Beginner lessons and prerequisites

Be comfortable with array positions, integer division, comparisons and loops. The array foundations and shared programming track cover those prerequisites. A separate feasibility function also needs to be correct before an outer binary search can use it to locate a boundary.

Be comfortable with indices, integer division, comparisons and loops. Understand the difference between a closed range and a half-open range, then follow one convention consistently. Before searching possible answers, learn to write a separate feasibility check and explain which direction preserves success. The outer search cannot repair an incorrect or nonmonotonic check.

  • Trace one and two candidates to check that each iteration makes progress.
  • Keep a qualifying boundary represented even when searching for an earlier answer.
  • Use numeric types that can hold bounds, accumulated totals and candidate products.