Search Ctrl K
Home / Tools
THE FEUTEX TOOLKIT

Binary Search Comparison Bound

Estimate worst-case comparisons and compare with a linear lookup bound.

Developer workspace● Runs in your browser
01 Your input
02 Your result
View or copy raw result data
FormulaWorst-case comparisons per lookup = Math.floor(Math.log2(n))+1; Worst-case comparisons for all lookups = (Math.floor(Math.log2(n))+1)*queries; Linear scan worst case per lookup = n

Made for real tasks

  • Estimate worst-case comparisons and compare with a linear lookup bound.
Explore step-by-step workflows →

Worked example

Inputs

Sorted elements
1000000 elements
Independent lookups
1000 lookups

Expected results

Worst-case comparisons per lookup
20 comparisons
Worst-case comparisons for all lookups
20000 comparisons
Linear scan worst case per lookup
1000000 comparisons

Load the example in the workspace to reproduce these results. Display rounding does not change the underlying calculation.

How to use this tool

  1. Enter sorted elements, independent lookups in the displayed units.
  2. Calculate the scenario, then compare it with measurements before changing a system.

Try this example

{
  "n": 1000000,
  "queries": 1000
}

Accuracy and scope

Classic binary search with constant-time comparisons and random access; excludes index construction and cache effects.

Is my data uploaded?

This tool runs locally in your browser. Input and output are not sent to a processing server. Copy or download your result before leaving the page.