Past questions › sdd2024-q27
2024 3 marks Extended response The Software Engineering Project (Year 12) Reading and modifying an algorithm
NESA 2024 HSC Software Design and Development (OLD syllabus) - Section II Question 27, with NESA Marking Guidelines
A palindrome is a word that reads the same forward and backward, such as the words | 3 ‘refer’ and ‘noon’. The following code fragment checks whether a word is a palindrome. 1 | BEGIN PalindromeCheck(word, palindrome) 2 | palindrome = TRUE 3 | F=1 4 | N = number of letters in word 5 | L=N 6 | REPEAT th | th 7 | IF F letter of word is not equal to L letter of word THEN 8 | palindrome = FALSE 9 | END IF 10 | L = L–1 11 | F = F+1 12 | UNTIL F > N 13 | RETURN palindrome 14 | END PalindromeCheck There are no errors in the code fragment. Explain the effect of changing line 12 to the following code. 12 | UNTIL F > N/2 OR palindrome = FALSE
Marking criteria
[Question 27] Criteria | Marks • Provides correct explanations for BOTH modifications | 3 • Provides a correct explanation for ONE modification | 2 • Demonstrates some understanding of the algorithm | 1
Sample answer
Sample answer: UNTIL F>N/2 – once the process has reached halfway, the same checks would be repeated unnecessarily. Adding ‘OR palindrome = FALSE’ – there is no need to keep checking once a non-matching letter is found. In both cases, the loop can be exited early, improving efficiency.