O(log n) passos
- Created by
- Renato Passos, Eng. de Software
- Reviewed by
- Renato Passos, Eng. de Software
Last updated: Apr 18, 2026
About this calculator
The 'O(log n) steps' calculator helps compute the time complexity of a binary search algorithm, represented by log₂(n). This formula indicates the maximum number of steps required to find an element in a sorted list, halving the data at each iteration. It is widely used in programming to optimize search algorithms in large datasets.
The calculation uses the formula log₂(n), where 'n' is the total number of elements in the list. For example, if there are 8 elements, log₂(8) = 3, meaning up to 3 steps are needed. The calculator accepts positive integers only, as logarithms for negative numbers or zero are undefined.
Use this tool when estimating the efficiency of a binary search algorithm, such as in registration systems, databases, or code performance analysis. It is ideal for developers working on algorithms who want to understand how operations scale with data size.
Cautions: Binary search requires the list to be sorted. If the data is unsorted, the calculator's results become irrelevant. Additionally, for 'n' values that are not powers of 2, the logarithm rounds up to ensure the minimum guaranteed steps.
Frequently asked questions
Why log₂(n) instead of another base?
Base 2 is used because binary search halves the data at each step. Other bases wouldn't reflect this reduction pattern.
What if the number of elements isn't a power of 2?
The calculator rounds up the logarithm result to ensure the calculated steps are sufficient for any 'n'.
How does this relate to real execution time?
log₂(n) represents the theoretical worst case. Actual time depends on implementation and processor speed.
Can I use this calculator for unsorted arrays?
No. Binary search only works on sorted arrays. Use this calculator only when data is in ascending or descending order.