跳到主要内容

评分标准模式


Common MS Points for Sorting Algorithms

Bubble Sort (4–5 marks)

PointTypical wordingMarks
Procedure/function headerFUNCTION bubbleSort(arr) RETURNS ARRAYA1
Outer loopFOR i ← 0 TO n-2 or FOR i ← 1 TO n-1A1
Inner loopFOR j ← 0 TO n-2-iA1
Adjacent comparisonIF arr[j] > arr[j+1] — must be > for ascendingA1
Swap + returnSwap using temp variable; RETURN arr at endA1

Insertion Sort — Iterative (4 marks)

PointTypical wordingMarks
Loop from 1st elementFOR i ← 1 TO n-1 (do not start at 0)A1
Store current itemcurr ← arr[i] or key ← arr[i]A1
While loop (shift)WHILE j ≥ 0 AND arr[j] > curr — both conditions neededA1
Insertarr[j+1] ← curr after shiftingA1

Insertion Sort — Recursive (4 marks)

PointTypical wordingMarks
Base caseIF n ≤ 1 THEN RETURNA1
Recursive callCALL insertionSortRec(arr, n-1)A1
Shift loopWHILE j ≥ 0 AND arr[j] > keyA1
Insert keyarr[j+1] ← keyA1

Generic MS Notes

  • M marks (method) are awarded for correct structure / approach even if there are minor errors
  • A marks (accuracy) require correct implementation — syntax errors lose A marks
  • If a question says "write a procedure", do not use RETURN — use parameters by reference
  • If a question says "write a function", a RETURN is required
Example MS — 9618/s24/qp/42 Q3 (Bubble Sort)

M1 Correct outer loop and inner loop structure (nested)
A1 Outer loop correct number of passes (n-1)
A1 Inner loop correct bound (n-1-i)
A1 Correct adjacent comparison (arr[j] > arr[j+1])
A1 Correct swap and return

Example MS — 9618/s24/qp/41 Q1d (Insertion Sort)

M1 Iterates from index 1 to last element
A1 Stores current element
A1 Shifting loop with correct conditions
A1 Inserts element at correct position