Binary trees

Binary trees are a type of tree data type where each node has a maximum of two child nodes.
They can represent a lot of different systems, such as a binary search, or even certain turing complete systems like lambda calculus.

Representations

Binary trees can be represented in lots of different ways, but the two main ones are linked node representation and array representation.

Linked node representation uses the same principle as linked lists, however this time with two "next" pointers to represent a left or a right node (or a null pointer to show where there isnt one).
The advantages of this is that it is easy to grow or shrink the tree as just a few pointer changes are needed, however it takes up more memory then other options as it requires storing 2 pointers for each node.

Array representation stores the binary tree in an array, using the algorithm where the left and right child node are at indexes 2n+1 and 2n+2 from the parent node respecitvely, with the root node at index 0.
The advantages is it is a lot easier to search down the tree as you dont have to travel down pointers, however the array size has to be predetermined and if the tree has a lot of empty nodes, then most of the array will be empty which wastes memory.

Example:

This is an example using the array representation