Question: Algorithm Count ( n ) / / Input: A positive integer n . i 2 while ( i < n ) do i i 2

Algorithm Count(n)
// Input: A positive integer n.
i 2
while (i < n) do
i i2
x x +1
return i
What does this algorithm compute when you call Count(n)? Your answer should be a function of n. Show all your work without skipping any steps.
b. Find a Theta (\theta ) notation for the number of times the statement x = x +1 is executed.

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!