Binary Search

How to explain the time complexity of binary search is O(lgn):

Reference: http://stackoverflow.com/questions/8185079/how-to-calculate-binary-search-complexity

Each time we cut our searching space by half, so the question is if the original searching space is N, and each time we cut it half, after how many times cutting, we get 1. The formula is 1 = N / 2^x, so N = 2^x, so x = lg(N).

results matching ""

    No results matching ""