Skip to content
Related Articles

Related Articles

Applications of tree data structure

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 29 Nov, 2022
Improve Article
Save Article

Applications of tree data structure

What is Tree Data Structure?

Tree is collection of nodes. A tree is a hierarchical data structure. Tree is a non-linear data structure which contains nodes and edges. 

Terminologies used in Tree:

According to the above example image of a tree

  • Nodes: A B C D E F G H I J K L M N O P
  • Root: A
  • Internal Nodes: A B C D E F G H I J
  • External nodes:  K L M N O P
  • (Parent , Child) : (A, B and C), (B, D and E), (C, G and F),(H, K and L), (I, M and N) , (J, O AND P).
  • Siblings : (B,C) , (D, E), (G, F), (K, L), (M, N) ,(O, P)

Why Tree to use Data Structure? 

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

  1. 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: 


  1. 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.
  2. 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.
  3. 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 of Tree Data Structure: 

  1. Store hierarchical data, like folder structure, organization structure, XML/HTML data.
  2. Binary Search Tree is a tree that allows fast search, insert, delete on a sorted data. It also allows finding closest item
  3. Heap is a tree data structure which is implemented using arrays and used to implement priority queues.
  4. B-Tree and B+ Tree : They are used to implement indexing in databases.
  5. Syntax Tree:  Scanning, parsing , generation of code and evaluation of arithmetic expressions in Compiler design.
  6. K-D Tree: A space partitioning tree used to organize points in K dimensional space.
  7. Trie : Used to implement dictionaries with prefix lookup.
  8. Suffix Tree : For quick pattern searching in a fixed text.
  9. Spanning Trees and shortest path trees are used in routers and bridges respectively in computer networks
  10. As a workflow for compositing digital images for visual effects.
  11. Decision trees.
  12. Organization chart of a large organization.
  13. In XML parser.
  14. Machine learning algorithm.
  15. For indexing in database.
  16. IN server like DNS (Domain Name Server)
  17. In Computer Graphics.
  18. To evaluate an expression.
  19. In chess game to store defense moves of player.
  20. In java virtual machine.


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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!