📖 Explanation
The loop variable j is initialized to 1 and is updated in each iteration as j=2i for i=0,1,2,…,k.
The condition j≤n is evaluated at the start of each iteration, and the loop continues as long as 2i≤n.
This condition holds for all i such that 2i≤n, which is equivalent to i≤log2n.
The maximum integer value for i is k=⌊log2n⌋.
Since the loop executes for i=0,1,…,k, there are k+1 iterations.
Thus, the number of comparisons made during these iterations is ⌊log2n⌋+1.