A binary tree can be stored with pointers, as a set of linked nodes, or in an array, using positions instead of pointers. This page explains both and shows when each is suitable.
Linked representation
Each node holds a value and two pointers:
Node of a binary tree
struct node { struct node *left; /* left subtree, or NULL */ int value; struct node *right; /* right subtree, or NULL */};
The tree is reached through a pointer to the root; an empty tree is a NULL root pointer. Leaves have both pointers NULL. This representation suits any shape of tree and allows nodes to be inserted and deleted freely.
Array (sequential) representation
Number the positions of a complete binary tree level by level, left to right, starting at 0. Store the node at position i in A[i]. Then, for the node at index i:
left child=2i+1,right child=2i+2,parent=⌊2i−1⌋(i>0).
Positions where the tree has no node are marked as empty. For a complete tree no cell is wasted; for a skewed tree of height h the array needs 2h−1 cells for only h nodes.
Comparison
Linked
Array (sequential)
Memory
Two pointers per node
No pointers, but empty positions for missing nodes
Best for
Any shape; frequent insertions and deletions
Complete trees (e.g. heaps)
Parent of a node
Needs an extra parent pointer
⌊(i−1)/2⌋
Size limit
Grows with malloc
Fixed array size; a skewed tree of height h needs 2h−1 cells
Key takeaways
Linked: left, value, right; empty tree = NULL root.
Sequential (0-based): children at 2i+1, 2i+2; parent at ⌊(i−1)/2⌋.
Empty positions must be kept; complete trees waste nothing, skewed trees waste a lot.
Program 6.1’s rule (smaller left, larger right) builds a binary search tree.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Draw the sequential (array) representation of the binary tree in which A has children B and C, B has only a right child D, and C has children E and F.
Show worked answer
Number positions level by level from 0: A at 0; B at 1, C at 2; B’s left child position 3 is empty, D (B’s right child) at 4, E (C’s left) at 5, F (C’s right) at 6. Array: [A, B, C, –, D, E, F] (7 cells, one empty). Check: children of B (1) are at 3 and 4; children of C (2) at 5 and 6; parent of D (4) is ⌊3/2⌋=1 = B.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-208/trees/representing-binary-trees-in-memory/ to read this page.