Member-only story

Data Structures — Trees- Part-3

Eishta Mittal
1 min readMay 30, 2022

--

Tree Traversals

The term ‘tree traversal’ means traversing or visiting each node of a tree. There is a single way to traverse the linear data structure such as linked list, queue, and stack.

Previous part of trees series can be found here:-
https://eishta.medium.com/data-structures-trees-part-2-5a9efa82e41a

As discussed in the previous part , a tree can be traversed in multiple ways as follows —
1. DFS- Depth First Search
2. BFS- Breadth First Search

This part is focused on implementing the traversals both recursively and iteratively.

DFS- Depth First Search (Preorder, Inorder, PostOrder)

Recursive Approach of traversing a tree

Iterative Approach of traversing a tree( using stack)

--

--

Eishta Mittal
Eishta Mittal

Written by Eishta Mittal

Software Engineer passionate about Frontend Engineering

No responses yet