🎁 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

Stack vs Heap
Two memory regions: the stack stores function call data with automatic cleanup, while the heap stores dynamically allocated objects.
Debugging
The process of finding and fixing errors (bugs) in software code to ensure correct program behavior.
Closure
A function that captures and retains access to variables from its enclosing scope, even after that scope has finished executing.
Design Pattern
A reusable solution template for commonly occurring problems in software design.
Big O Notation
A mathematical notation that describes the worst-case performance of an algorithm as input size grows.
SOLID Principles Breakdown
Five object-oriented design principles that guide developers in creating maintainable, flexible, and scalable software systems.
View All Programming Concepts Terms →