[Verse 1]
Array stretches out like city blocks in rows
Thousand elements, but which one holds my code?
Linear search crawls slow, checking every door
Binary slash cuts time, mathematical lore
Sorted prerequisite, foundation that we need
Split the world in half, logarithmic speed
Middle element speaks, greater or less than target
Navigate left or right, precision like a marksman
[Chorus]
Divide and conquer, slice it clean in two
Big O log n, that's the magic we pursue
Low and high pointers dancing through the maze
Binary search cuts, exponential delays
Cut it, split it, narrow down the scope
Logarithmic time gives algorithms hope
[Verse 2]
Initialize the bounds, low starts at index zero
High begins at length minus one, our hero
While low stays less than or equal to high
Calculate the middle, no floating point lie
Integer division keeps the index whole
Compare with target, let the logic roll
Match means victory, return the golden spot
Less than means go right, greater means we're not
[Chorus]
Divide and conquer, slice it clean in two
Big O log n, that's the magic we pursue
Low and high pointers dancing through the maze
Binary search cuts, exponential delays
Cut it, split it, narrow down the scope
Logarithmic time gives algorithms hope
[Bridge]
Million elements shrink to twenty checks
Billion records bow to thirty flex
Exponential growth meets logarithmic blade
Every iteration, half the search has frayed
Telephone book thickness, find a name so fast
Binary beats linear, algorithms that last
[Verse 3]
Edge cases lurking, empty arrays return
Negative one signals nothing there to learn
Duplicate values, find the first occurrence
Modify the logic, leftward convergence
Recursive beauty or iterative might
Same complexity, same algorithmic sight
Sorted arrays unlock this secret door
Unsorted data needs preprocessing more
[Chorus]
Divide and conquer, slice it clean in two
Big O log n, that's the magic we pursue
Low and high pointers dancing through the maze
Binary search cuts, exponential delays
Cut it, split it, narrow down the scope
Logarithmic time gives algorithms hope
[Outro]
From databases massive to simple integer lists
Binary search conquers what linear resists
Logarithmic scaling, programmer's best friend
Efficiency revolution that will never end