Prachi K.

asked • 10/11/20

Find the total number of comparisons:

Find out total number of comparisons made in the execution of the loop for any n > 0 in term

of CEILING or FLOOR function.

int j, n;

j = 1;

while (j <n)

j = j*2;


I'm not able to understand about the function I should use in this case(j<n).

1 Expert Answer

By:

Inactive Tutor answered • 10/11/20

Tutor
New to Wyzant

Prachi K.

The 10000 input is taking 15 iterations not 14. And log(n) is totally fine but which function will be used ceiling or floor?
Report

10/11/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.