Question: 3. (a) Consider the procedure procedure Loopsl (n, a positive integer) 1, for i 1 to n for j = i to n print (i,j)

 3. (a) Consider the procedure procedure Loopsl (n, a positive integer)

3. (a) Consider the procedure procedure Loopsl (n, a positive integer) 1, for i 1 to n for j = i to n print (i,j) i. In terms of n, how many ordered pairs are printed? ii. What is the runtime in notation of this procedure? (b) Consider the procedure procedure Loops2 (n, a positive integer) I. for k = 1 to n-2 for i=k+1 to n-1 for j=i+ 1 to n print (i,j) i. In terms of n, how many ordered pairs are printed? ii. what is the runtime in notation of this procedure? (c) Consider the procedure procedure Loops3(n, a power of 2) 1, for i 1 to n =n while j >1 print (i,j) i. In terms of n, how many ordered pairs are printed? ii. What is the runtime in notation of this procedure

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!