educative.io

Educative

Tree representation and traversal technique

I could not fine how tree can be represented and different ways to traverse like other DS in the module.


Type your question above this line.

Course: https://www.educative.io/collection/5642554087309312/5679846214598656
Lesson: https://www.educative.io/collection/page/5642554087309312/5679846214598656/120004

Hi @Arpan_Paliwal

Trees are not linear data structures, so we cannot traverse them in the same way we traverse linear DS like array lists and linked lists.

Tree Traversal Algorithms can be classified broadly in the following two categories by the order in which the nodes are visited:

1. Depth-First Search (DFS) Algorithm
2. Breadth-First Search (BFS) Algorithm

These two algorithms further have four famous variations:

  1. Pre-order traversal (follows DFS)
  2. In-order traversal (follows DFS)
  3. Post-order traversal (follows DFS)
  4. Level-order traversal (follows BFS)

My question was all the program uses BinaryTreeNode.java.
Want to understand the internals of this class. How is a tree represented?

In the lessons no where such information is present.