April 2000
AP207 : ADVANCED PROGRAMMING TECHNIQUES

QUESTION 4

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 4

(a)(i)Briefly describe the selection sort algorithm.[2 marks ]
(ii)Briefly describe the bubble sort algorithm.[2 marks ]
(iii)State which of these two technique will be required to perform fewer
comparison in a worst-case scenario.[1 mark ]

(b)The procedure SelectionSort takes an unsorted list x and sorts the list into
ascending order.Show the state of the list given below on each pass of the procedure SelectionSort
26 3 25 17 6 40 39
[5 marks ]

(c)Define the procedure SelectionSort the signature of which is given below,which takes a list x which is an array of integers of length ListSize and performs a selection sort on x such that the items are placed in ascending order.
PROCEDURE SelectionSort(VAR x : ListType; ListSize : INTEGER);
[5 marks ]