**Why Tree?**

Unlike Array and Linked List, which are linear data structures, tree is hierarchical (or non-linear) data structure.

- One reason to use trees might be because you want to store information that naturally forms a hierarchy. For example, the file system on a computer:
file system

———–/ <-- root / \ ... home / \ ugrad course / / | \ ... cs101 cs112 cs113

- If we organize keys in form of a tree (with some ordering e.g., BST), we can search for a given key in moderate time (quicker than Linked List and slower than arrays). Self-balancing search trees like AVL and Red-Black trees guarantee an upper bound of O(Logn) for search.
- We can insert/delete keys in moderate time (quicker than Arrays and slower than Unordered Linked Lists). Self-balancing search trees like AVL and Red-Black trees guarantee an upper bound of O(Logn) for insertion/deletion.
- Like Linked Lists and unlike Arrays, Pointer implementation of trees don’t have an upper limit on number of nodes as nodes are linked using pointers.

**Other Applications : **

- Store hierarchical data, like folder structure, organization structure, XML/HTML data.
- Binary Search Tree is a tree that allows fast search, insert, delete on a sorted data. It also allows finding closest item
- Heap is a tree data structure which is implemented using arrays and used to implement priority queues.
- B-Tree and B+ Tree : They are used to implement indexing in databases.
- Syntax Tree: Used in Compilers.
- K-D Tree: A space partitioning tree used to organize points in K dimensional space.
- Trie : Used to implement dictionaries with prefix lookup.
- Suffix Tree : For quick pattern searching in a fixed text.
- Spanning Trees and shortest path trees are used in routers and bridges respectively in computer networks
- As a workflow for compositing digital images for visual effects.

References:

http://www.cs.bu.edu/teaching/c/tree/binary/

http://en.wikipedia.org/wiki/Tree_%28data_structure%29#Common_uses

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Tango Tree Data Structure
- Applications of Minimum Spanning Tree Problem
- Advantages of Trie Data Structure
- Overview of Data Structures | Set 2 (Binary Tree, BST, Heap and Hash)
- Build Binary Tree from BST such that it's level order traversal prints sorted data
- Applications of BST
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
- Check if max sum level of Binary tree divides tree into two equal sum halves
- Print Binary Tree levels in sorted order | Set 3 (Tree given as array)
- Given level order traversal of a Binary Tree, check if the Tree is a Min-Heap
- Convert an arbitrary Binary Tree to a tree that holds Children Sum Property
- Check whether a binary tree is a complete tree or not | Set 2 (Recursive Solution)
- Construct XOR tree by Given leaf nodes of Perfect Binary Tree
- Convert a given Binary tree to a tree that holds Logical OR property
- Convert a given Binary tree to a tree that holds Logical AND property
- Check if a given Binary Tree is height balanced like a Red-Black Tree
- Sub-tree with minimum color difference in a 2-coloured tree
- Minimum difference between any two weighted nodes in Sum Tree of the given Tree