i know that 1/2^k = 1 from infinite GP but how is n/2^k=1 then ??
Why is n/2^k=1?
hello @mehulbhandari358
In binary search size of array get half on each iteration right?
so we can represent size after each iteartion as
after iteration 0 -> N
after iteration 1 -> N/2
after iteration 2 -> N/2^2
after iteration 3 -> N/2^3
after iteration 4 -> N/2^4
after iteration 5 -> N/2^5
.
.
after iteration k -> N/2^k
now we want to know after how many iterations our array size will become 1.
let say it is 1 after k iterations.
then using above formula we can write N/2^k=1
N=2^k
k=log2(N)