Linked structures
1.[2p] Why is indexing a singly linked list rather than ?
Why is indexing a singly linked list rather than ?
2.[2p] A structure holds 10,000 elements. Inserting at position 100, how many elements does a dynamic array have to shift?
A structure holds 10,000 elements. Inserting at position 100, how many elements does a dynamic array have to shift?
3.[2p] A singly linked list can delete a node in constant time given only a pointer to that node.
A singly linked list can delete a node in constant time given only a pointer to that node.
4.[2p] A ring buffer has capacity 8, head at slot 6, and holds 5 elements. Which slot will the next enqueue write to?
A ring buffer has capacity 8, head at slot 6, and holds 5 elements. Which slot will the next enqueue write to?
5.[2p] Match each structure to the discipline it enforces.
Match each structure to the discipline it enforces.
Stack
Queue
Deque
last in, first out
insertion and removal at both ends
first in, first out
Show the answer
Stack: last in, first out Queue: first in, first out Deque: insertion and removal at both ends
6.[3p] Which are genuine reasons to choose a doubly linked list over a dynamic array?
Which are genuine reasons to choose a doubly linked list over a dynamic array?
Select all that apply
7.[3p] Scanning a million 8-byte elements is roughly eight times faster in an array than in a linked list because
Scanning a million 8-byte elements is roughly eight times faster in an array than in a linked list because
8.[2p] An LRU cache uses a doubly linked list rather than an array because
An LRU cache uses a doubly linked list rather than an array because
9.[2p] To find an element whose position is unknown, both an array and a linked list cost in the worst case.
To find an element whose position is unknown, both an array and a linked list cost in the worst case.