Inorder traversal

315 views
247 views

Published on

inorder tree traversal

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
315
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Inorder traversal

  1. 1. TREE TRAVERSAL TREE TRAVERSAL is the process of visiting each node in the tree exactly once.  It has three methods :  inorder traversal  preorder traversal  postorder traversal 
  2. 2. ALGORITHM Traverse the left subtree of root.  Visit the root.  Traverse the right subtree of the root 
  3. 3. CODE Inorder(ptr) { struct node*ptr; { if(ptr!=NULL) { inorder(ptr->left); printf(“%c”,ptr->info); inorder(ptr->right); } } }
  4. 4. Procedure InOrderPrint(pointer) pointer NOT NULL? InOrderPrint(left child) L print(data) P InOrderPrint(right child) R root A C B D E G H AnswerDBFEAGCJHL F J L
  5. 5.   By the method of traversal we can also find infix , postfix, prefix notation. Infix notation can be obtained by inorder traversal

×