What is a Tree?

In this chapter, we are going to give a basic introduction of Trees and discuss different components/terminologies used in Trees.


In this lesson, we will learn a hierarchical data structure known as a Tree. A tree consists of nodes (vertices) that are connected using pointers (edges). Trees are similar to Graphs; the key differentiating point is that a cycle cannot exist in a Tree.

The basic structure of a tree consists of the following components:

  • Nodes: Hold data
  • Root: The uppermost node of a tree
  • Parent Node: A node which is connected to one or more nodes on the lower level (Child Nodes).
  • Child Node: A node which is linked to an upper node (Parent Node)
  • Sibling Node: Nodes that have the same Parent Node
  • Leaf Node – A node that doesn’t have any Child Node

The figure below shows all the terminologies described above:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.