Six original Cambridge-style questions on implementing ADTs with arrays, records and pointers.
(Pointer + 1) MOD Size and keep a count.Using the record type TreeNode and the global variables in this lesson, write pseudocode for a function FindNode(SearchItem : INTEGER) RETURNS INTEGER that returns the index of the node holding SearchItem, or −1 if it is not in the tree.
ENDFUNCTION; local Current initialised to RootPointer. ✓Tree[Current].Data = SearchItem, return Current (or set a flag and exit the loop). ✓Tree[Current].Data, Current ← Tree[Current].LeftPointer. ✓Tree[Current].RightPointer. ✓An empty binary search tree uses nodes 0 to 9 in order from the free list. The values 40, 25, 60, 10, 30, 55, 75 are inserted in that order. Draw the tree and give the LeftPointer and RightPointer of nodes 0 and 1.
A circular queue uses Queue : ARRAY[0:9] OF STRING, FrontPointer, RearPointer and NumberInQueue. Write pseudocode for a procedure Enqueue(NewItem : STRING) that adds an item, or outputs an error message if the queue is full.
ENDPROCEDURE. ✓NumberInQueue = 10; output an error message if full. ✓RearPointer ← (RearPointer + 1) MOD 10. ✓Queue[RearPointer] ← NewItem. ✓NumberInQueue ← NumberInQueue + 1. ✓Using the linked list table in this lesson (StartPointer = 1, FreeListPointer = 2), state every value that changes when (a) DeleteItem("Ava") is run on the original table (b) DeleteItem("Eli") is run on the original table.
A delivery company wants to store the towns it serves and the roads between them, with the driving time for each road. Identify a suitable ADT, describe its key features and justify the choice.
Explain how a queue can be implemented using two stacks.
Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.