(a) Explain the difference between a static data structure and a dynamic data structure. [2]
(b) A stack is described as a LIFO data structure and a queue as a FIFO data structure. Explain what is meant by each of these terms. [2]
- (a) A static data structure has a fixed size/maximum number of items set when it is created (memory allocated at compile time / in advance)(1)
- (a) A dynamic data structure can grow and shrink in size during execution (memory allocated/freed at run time from the heap)(1)
- (b) LIFO (Last In First Out): the most recently added item in a stack is the first one removed(1)
- (b) FIFO (First In First Out): the item that has been in the queue longest/was added first is the first one removed(1)
- Answer: (a) Static: fixed size decided in advance; dynamic: size changes at run time. (b) LIFO: last item added is first removed; FIFO: first item added is first removed.
- Examiner tip: Expanding the acronym alone earns nothing – you must say which item is removed next.