Question: Consider the following pseudocode: for i = 0 to n - ceil ( n 2 ) for j = 0 to n - i -

Consider the following pseudocode:
for i=0 to n-ceil(n2)
for j=0 to n-i-2
if A[j]>A[j+1]
swap A[j] and A[j+1]
end for
end for
print (i)
end for
something =A[ceil(n2)-1]+A[n-ceil(n2)]2
(a) If this code is run on the following list, show the state of the list each time the i value is printed. Some of the rows are not necessary; just don't fill those in.
\table[[Start,15,10,7,9,5,3,1,6],[i=0:,,,,,,,,],[i=1 :,,,,,,,,],[i=2 :,,,,,,,,],[i=3 :,,,,,,,,],[i=4:,,,,,,,,],[i=5 :,,,,,,,,],[i=6:,,,,,,,,],[i=7:,,,,,,,,]]
(b) For the example in (a), what is the value of something at the end?
something =
(c) In general - not for the example in (a)- What is the value of something at the end?
 Consider the following pseudocode: for i=0 to n-ceil(n2) for j=0 to

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!