ALGORITHMS I 2026 TEST PAPER SOLVED
QUESTIONS AND SOLUTIONS
◉ Max-heap remove. Answer: Always a removal of the root, and is
done by replacing the root with the last level's last node, and
swapping that node with its greatest child until no max-heap
property violation occurs.
Complexity O(logN)
◉ Percolating. Answer: The upward movement of a node in a max-
heap
◉ Min-Heap. Answer: Similar to a max-heap, but a node's key is less
than or equal to its children's keys.
◉ Linked list vs Array. Answer: If a program requires fast insertion
of new data, a linked list is a better choice than an array.
◉ Abstract Data Type (ADT). Answer: A data type described by
predefined user operations, such as "insert data at rear," without
indicating how each operation is implemented.
,◉ List. Answer: An ADT for holding ordered data.
Data Structure Types: Array, linked list
◉ Tuple. Answer: Array Type
An immutable(fixed) container with ordered elements.
◉ Stack. Answer: An ADT in which items are only inserted on or
removed from the top of a stack.
*Last-in First-Out
Underlying data structures: Linked list
Push(stack, x), pop(stack), peek(stack), IsEmpty(stack),
GetLength(stack)
*Pop & peek should not be used on a empty stack.
◉ Stack operations. Answer: Example starting with stack: 99, 77
(top is 99).
Push(stack, x)
, Inserts x on top of stack
Push(stack, 44). Stack: 44, 99, 77
Pop(stack)
Returns and removes item at top of stack
Pop(stack) returns: 99. Stack: 77
Peek(stack)
Returns but does not remove item at top of stack
Peek(stack) returns 99. Stack still: 99, 77
IsEmpty(stack)
Returns true if stack has no items
IsEmpty(stack) returns false.
GetLength(stack)
Returns the number of items in the stack
GetLength(stack) returns 2.
◉ Queue. Answer: An ADT in which items are inserted at the end of
the queue and removed from the front of the queue.