adplus-dvertising
frame-decoration

Question

The complexity of Binary search algorithm is
int a = 0, i = N;
while (i > 0) 
{
a += i;
i /= 2;
}

a.

O(n)

b.

O(log n )

c.

O(n²)

d.

O(n log n)

Answer: (b).O(log n )

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. The complexity of Binary search algorithm is