GeekInterview.com
Series: Subject: Topic:
Question: 18 of 51

Post Order Binary Tree Traverse

Design a conventional iterative algorithm to traverse a binary tree represented in two dimensional array in postorder.
Asked by: Dheerendra_juli | Member Since Jul-2009 | Asked on: Jul 22nd, 2009

View all questions by Dheerendra_juli

Showing Answers 1 - 2 of 2 Answers
Sandhya.Kishan

Answered On : Mar 10th, 2012

View all answers by Sandhya.Kishan

In Postorder traversal sequence we first look for the left node then the right node and then the root. Algorithm:

Code
  1. void postOrder(tNode n)
  2. {
  3.  if(n==null)
  4.     return;
  5.     postOrder(n.left);
  6.    postOrder(n.right);
  7.     visit(n);
  8. }

  
Login to rate this answer.
Shikhar Singhal

Answered On : Jun 10th, 2013

when tree is implemented using linked list rather than 2-d array

Code
  1. void traverse(tree head)
  2. {
  3. if (head.left!=NULL)    traverse( head.left);
  4. if (head.right!=NULL)    traverse(head.right);
  5. printf("%d",&head);
  6. }

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.