Essential algorithms for GCSE and A Level Computer Science
Higher order data structures
Supported by some programming languages within the command set, programmers often implement these structures using the fundamental data structures as building blocks.
What is a stack?
A stack is an essential data structure for the operation of a computer. Items are “pushed” onto the top of the stack when added and “popped” off the top of the stack when deleted. It is also possible to “peek” at the top item without deleting it.
Imagine a stack of coins. A coin can be added or removed from the top but not the middle. The only way of accessing items in the stack is from the top.
A stack is known as a last-in, first-out or LIFO structure. The last item pushed must be the first item popped.
A stack has a “stack pointer” that always points to the node at the top of the stack.
An attempt to push an item to an already-full stack is called a stack overflow, while attempting to pop an item from an empty stack is called a stack underflow. Both should be considered before proceeding to push or pop the item in question.
A stack is often implemented using an array but can also be created using object-oriented techniques.
What extra is in the book?
This algorithm / data structure has its own dedicated chapter in the book, which includes:
A hard copy of the book is available on our shop and a free PDF copy is included for all premium subscribers.