TK Study

Past questions › sdd2021-q29

2021 3 marks Extended response The Software Engineering Project (Year 12) Tracing an algorithm (linear search)

NESA 2021 HSC Software Design and Development (OLD syllabus) - Section II Question 29, with NESA Marking Guidelines

Consider the following linear search algorithm. | 3 BEGIN ‘REM N = number of elements in the array Items Get String Found = FALSE Count = 1 WHILE Count <= N AND Found = FALSE IF Items(Count) = String THEN Display String, “ is in the array” Found = TRUE ENDIF Count = Count + 1 ENDWHILE IF Found = FALSE THEN Display String, “ is not in the array” ENDIF END Identify the variable that is used as a flag and explain how using a flag helps the efficiency of this algorithm.

Marking criteria

[Question 29] Criteria | Marks • Identifies the flag and explains how using it helps the efficiency of the algorithm • Identifies the flag and shows some understanding of its effect on the algorithm • Shows some understanding of flags OR the logic of the algorithm | 1

Sample answer

Sample answer: The variable Found is used as the flag. This is set to False until the String is located. The efficiency is improved by allowing the WHILE loop to be exited as soon as String is located, thus not requiring any further searching, reducing processing time.

Question page · Practise and get marked