C programming concepts
C programming made easy.
Menu
Home
C programming basics
Functions
Pointers
Arrays
Strings
Unions
Structures
DMA
Queue
Stack
Linked list
Binary tree
Binary search tree
Threaded binary tree
AVL Tree
Heap
Graphs
Sorting
Searching
Preorder traversal of binary tree
Concept
1.Visit the root.
2.Visit the left subtree.
3.Visit the right subtree.
Note
:
Root and left children
are visted from
top to bottom
stepwise.
On the other hand
,
right children
of nodes are visited from
bottom to top
stepwise.
This is exactly what preorder traversal demands.
Below example will make things more clear.
Preorder traversal :
ABCDEFG
More
Non recursive implementation
No comments:
Post a Comment
Home
Subscribe to:
Posts (Atom)
No comments:
Post a Comment