# Representation of Binary Trees in Memory

**Binary trees** in memory can be represented by

- Array
- Linked Lists

### Representation through Arrays

Binary Trees can be represented using **1-D array** in memory(Fig 1).The rule to store** binary tree** in array are :

- The values of binary tree is stored in an array called as
**tree**. - The root of the tree is stored at
**first location**i.e. at**tree[0](0 index)**. - The
**left child**of tree is stored at**2i +1**and right child is stored at^{ }**2i+2**location. -
The
**maximum size**of the array tree is given as**2**, where^{d+1}-1**d**is the**depth**of the**tree**. -
An
**empty tree**or**sub-tree**is specified using**NULL**. If**tree[0] = NULL**, then it means that**tree is empty.**

### Representation through Linked List

In linked list representation,every** node** of the tree has **three parts** : the **data**/root element,the** pointer** to the** left node** and the **pointer** to the **right node**(Fig 2).In C,tree is built using structures by the following way :

struct node { struct node* left; int data; struct node* right; };

## Comments

So empty here ... leave a comment!