Question: 1. For the following four program fragments, give an analysis of the running time. (Use Big- O ) (12 pts) (a) Sum:=0;fori:=1toNdoforj:=itoNdofork:=jtoNdoSum:=Sum+1; (b) Sum:=0;fori:=1toNNdoforj:=1to10000doSum:=Sum+1; (c)

1. For the following four program fragments, give an analysis of the running time. (Use Big- O ) (12 pts) (a) Sum:=0;fori:=1toNdoforj:=itoNdofork:=jtoNdoSum:=Sum+1; (b) Sum:=0;fori:=1toNNdoforj:=1to10000doSum:=Sum+1; (c) Sum :=0; for i:=1 to N do if i>10 for j:=1 to i do Sum := Sum +1 (d) int product(int n){ if n=0 then return 0 ; else return product(n/2); \}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
