Data is stored in the array NameList [1:10]. This data is to be sorted. a) i) Copy

Question:

Data is stored in the array NameList [1:10]. This data is to be sorted.
a) i) Copy and complete this pseudocode algorithm for an insertion sort.

ii) A special case is when NameList is already in order. The algorithm in part a) i) is applied to this special case.
Explain how many iterations are carried out for each of the loops.
b) An alternative sort algorithm is a bubble sort:

i) As in part a) ii), a special case is when NameList is already in order. The algorithm in part b) is applied to this special case.
Explain how many iterations are carried out for each of the loops.
ii) Rewrite the algorithm in part b), using pseudocode, to reduce the number of unnecessary comparisons.
Use the same variable names where appropriate.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: