The chapter in short
Computational structures, or data structures, organise data so it can be used efficiently. The right structure makes a program faster and simpler.
The chapter covers arrays, stacks, queues, linked lists, trees and graphs, with their operations and uses.
Data structureStackQueueLinked listBinary treeGraph
Key points
- An array stores elements of the same type in contiguous memory, accessed by index.
- A stack is last in, first out: push and pop work at the top.
- A queue is first in, first out: enqueue at the rear, dequeue at the front.
- A linked list is a chain of nodes, each pointing to the next.
- A tree is a hierarchy of nodes with one root; a binary tree node has at most two children.
- A graph is a set of vertices joined by edges, used for networks and maps.
Definitions
- 1
Data structure
A way of organising and storing data for efficient access and change.
- 2
Stack
A LIFO structure where items are added and removed at the top.
- 3
Queue
A FIFO structure where items join at the rear and leave from the front.
- 4
Linked list
A sequence of nodes in which each node stores data and a link to the next.
- 5
Binary tree
A tree in which each node has at most two children.
- 6
Graph
A set of vertices connected by edges.