Question 1(e) 2015 · October-November · Paper 23 · 6 marks
Reveal official mark-scheme answer

Official answer for Question 1
Part (e)
Part (e)
Mark as follows:
- change outer FOR loop to a REPEAT/WHILE loop
- decrementing the iterations of the FOR loop
- introduce a Boolean variable NoSwaps (or similar)
- initialise Boolean variable correctly (inside outer loop and outside inner loop)
- terminate REPEAT loop when no swaps made
- leave comparison and swapping code the same
- change upper limit of inner loop to NumberOfCourses – x (instead of 49)
Question 23
Show text version of question
Question 1
Part (e)
Part (e)
Ravi wants to write a procedure to sort the records in the array Course. The records will
be sorted into ascending order of course fee. The array contains records for each course provided. The remaining array elements contain dummy records.
One of his students has written a sorting algorithm:
PROCEDURE SortData FOR x ← 1 TO 49 FOR y ← 1 TO 49 IF Course[y].CourseFee > Course[y + 1].CourseFee THEN TempRecord ← Course[y] Course[y] ← Course[y + 1] Course[y + 1] ← TempRecord ENDIF ENDFOR ENDFOR ENDPROCEDURE
An integer variable, NumberOfCourses, will contain the number of courses for which data are stored in the array.
Improve the algorithm so that no unnecessary comparisons are made.
PROCEDURE SortData(NumberOfCourses)
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
Question 6
Why this question appears here
71% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9691_w15_qp_23.pdf
