Past-paper question · 2024 May-June · Paper 32 · Q8(b)

Question 8(b) 2024 · May-June · Paper 32 · 8 marks

Question 8

Part (b)

Question 8

Part (a)

Complete the pseudocode to find an item in a 1D array Widgets of type STRING, using a

linear search. DECLARE Widgets : ARRAY[1:50000] OF STRING DECLARE TopOfList : INTEGER DECLARE EndOfList : INTEGER DECLARE Count : INTEGER DECLARE ToFind : STRING DECLARE Found : BOOLEAN DECLARE NotInList : BOOLEAN TopOfList

Question 1

EndOfList 50000 OUTPUT "Enter the name of the item you wish to find " INPUT ToFind ………………………………………………………………………………………………………………………………… NotInList FALSE Count TopOfList WHILE …………………………………………………………… AND ……………………………………………………………………… IF ……………………………………………………………………………………………………………………………… THEN Found TRUE ENDIF Count Count + 1 IF …………………………………………………………………………………………………………………………… THEN NotInList TRUE ENDIF ENDWHILE IF Found = TRUE THEN OUTPUT "Item found at position ", Count - 1, " in array" ELSE OUTPUT "Item not in array" ENDIF

[4]

Part (b)

Compare the methods used by the linear and binary search algorithms to find an item in an

array. Refer to Big O notation in your answer. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... .............................................................................................................................................

[4]

Question 10

Reveal official mark-scheme answer Official mark-scheme answer for 8(B)

Mark scheme 9618_s24_ms_32.pdf →

Topic relevance

Why this question appears here

98% assigned-topic match · Algorithm design and problem-solving › Algorithms

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 9618_s24_qp_32.pdf

Keep practising this topic