When he is taking log on both side step is not clear

log 2^k=log n
it sould be?
but it is shown
log 2^k=n
how?

hello @gaurav_kumar
In binary search size of array get half on each iteration
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)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.