327 views

1 Answer

Best answer
4 votes
4 votes
Loop2(n)
p <-- 1 
for i <-- 1 to 2n do 
    p  <-- p*i 

Variable used in for loop is i. variable modify after each iteration is p actually. i remain unchange. 
So for loop will run n time and complexity will be O(n).
selected by
Answer:

Related questions

2 votes
2 votes
1 answer
2
Bikram asked Oct 4, 2016
328 views
The Matrix Chain-Product dynamic programming Algorithm runs in _______linear timeexponential timequadratic timecubic time
3 votes
3 votes
1 answer
4
Bikram asked Oct 4, 2016
500 views
Let we have 3 steps of an arbitrary program fragment whose running times are $O(n^2), \: O(n^3)$ and $O(n\log n)$, then the running time of whole program is$O(n^3)$$\Omeg...