iterative tree traversal

Inorder Successor of node in Binary Tree Using Parent Pointer

Introduction This is the sixth article in the Tree Traversals - Online Classes. This article presents ways to find out inorder successor of node in binary tree. Before we jump into the code it would be good to correctly define the meaning of the problem. Definition - Inorder Successor of node in Binary Tree If a node K is called the inorder successor of node N then K must be visited immediately after N in a inorder traversal of the tree. Below is a more formal definition of Inorder Successor: If the node has a right sub-tree, then inorder successor is the left most node of the rig...
Read More

Level Order Tree Traversal

Introduction This is the third article in the Tree Traversals - Online Classes. I have written many articles about non-linear data structures and their traversals. But the more you dive in you can find many more ways to traverse a tree. Here we try to solve the level order tree traversal for a binary tree and we will also try to figure out other variations of this traversal. This can we precisely extended for a n-ary tree as well. Defining the problem Let us consider the above tree, if we follow the blue line from root till end and print all the nodes, we will end up printing the lev...
Read More

Hierarchical Datastructure – Iterative Tree Traversals

[nextpage title="Introduction"] This is the second article in the Tree Traversals - Online Classes. This is the sixth article in the series of non-linear data structures, to read more about the previous article, please check the topic Hierarchical Datastructure – Tree Traversals. To get updates on the coming articles in the series, please use the Subscribe feature on the right panel. Purpose of article We are already done with the constructing a binary tree and doing basic operations like creating a tree, adding a node, removing a node and all the traversals. There are situations when we...
Read More