9618_w22_qp_32
A paper of Computer Science, 9618
Questions:
11
Year:
2022
Paper:
3
Variant:
2

Login to start this paper & get access to powerful tools

1
4
10
11
A simplified linked list is used to store the names of flowers in alphabetical order. It is implemented using two 1D arrays: • Flower stores the names of the flowers. • NextPointer stores the pointer to the next flower name in the list. HeadPointer indicates the index of the first flower name in the linked list. HeadPointer When the end of the linked list is reached, the next pointer has the value of 0. The following table shows the initial content of the arrays. Index Flower NextPointer Rose Marigold Foxglove Iris Daisy Dahlia Saxifrage Lupin Lily Hydrangea Several flower names have been deleted from the linked list. These are crossed out in the following table. Complete the table to show the new values of HeadPointer and NextPointer to keep the remaining flower names in alphabetical order. HeadPointer Index Flower NextPointer Rose Marigold Foxglove Iris Daisy Dahlia Saxifrage Lupin Lily Hydrangea Complete the pseudocode algorithm so that it achieves the following when applied to the arrays: • The flower name is input. • The linked list is searched, in order, for the flower name. • If the flower name is found, an appropriate message is output to indicate it has been found. • If the flower name is not found, an appropriate message is output to indicate it has not been found. • The algorithm terminates when the next pointer value is 0. Pointer HeadPointer Found OUTPUT "Enter a flower name " …………………………………………………………………. …………………………………………………………………. IF Flower[Pointer] = FlowerName THEN Found Pointer Pointer ELSE …………………………………………………………………. ENDIF ENDWHILE …………………………………………………………………. OUTPUT Flower[Found], " is found" ELSE …………………………………………………………………. ENDIF Explain how you could improve the simplified linked list structure.