🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Programming Concepts Beginner

What is Binary Search?

An efficient search algorithm that finds a target value in a sorted array by repeatedly dividing the search interval in half.

Binary search compares the target to the middle element. If smaller, search the left half; if larger, search the right half. Each step eliminates half the remaining elements, giving O(log n) time complexity — searching 1 million items takes at most 20 comparisons.

Prerequisites: the data must be sorted. Binary search is used in database index lookups, dictionary searches, and finding insertion points. Variations include lower/upper bound searches and bisection methods for continuous functions.

Related Terms

Hash Table
A data structure that maps keys to values using a hash function, providing average O(1) time complexity for lookups, insertions, and deletions.
Unit Testing
Testing individual components or functions of a program in isolation to verify they work correctly.
Refactoring
Restructuring existing code without changing its external behavior to improve readability, maintainability, and performance.
Linked List
A linear data structure where elements are stored in nodes, each containing data and a pointer to the next node in the sequence.
Concurrency
The ability of a program to manage multiple tasks that can make progress during overlapping time periods.
Functional Programming
A programming paradigm that treats computation as the evaluation of mathematical functions, avoiding state changes and mutable data.
View All Programming Concepts Terms →