Question: Assuming n and i are integer variables and n was assigned a positive integer, the big - O of the following algorithm is _ _

Assuming n and i are integer variables and n was assigned a positive integer, the big-O of the following algorithm is _________.
i = n;
table row blank blank end tablewhile (i >0)
table row blank end table{
table row blank blank end table cout << i << endl;
table row blank blank end tabletable row blank end tablei /=2;
table row blank end table}
O(log(n))
O(n)
O(n squared)
O(2 to the power of n)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!