๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout 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

Clean Code
Code that is easy to read, understand, and maintain - following consistent conventions, meaningful naming, and single-responsibility functions.
Regex (Regular Expression)
A sequence of characters that defines a search pattern, used for string matching, validation, and text manipulation.
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.
Functional Programming
A programming paradigm that treats computation as the evaluation of mathematical functions, avoiding state changes and mutable data.
Code Smell
A surface indication in code that usually corresponds to a deeper problem in the system, suggesting the need for refactoring.
Garbage Collection
An automatic memory management process that identifies and reclaims memory no longer in use by a program.
View All Programming Concepts Terms โ†’