Postorder traversal of a binary tree, Data Structure & Algorithms

Assignment Help:

Postorder traversal of a binary tree

struct NODE

{

struct NODE *left;

int value;     /* can take any data type */

struct NODE *right;

};

postorder(struct NODE *curr)

{

if(curr->left != NULL) postorder(curr->left);

if(curr->right != NULL) postorder(curr->right);

printf("%d", curr->value);

}

In a preorder traversal, first (pre) the root is visited and then the left & right sub- trees are traversed. In a postorder traversal, first the left sub-tree is visited, followed by right sub-tree which is then followed through root. In inorder traversal, first the left sub- tree is visited, followed by root, followed by right sub-tree.


Related Discussions:- Postorder traversal of a binary tree

Conversion of general trees to binary trees, Taking a suitable example expl...

Taking a suitable example explains how a general tree can be shown as a Binary Tree. Conversion of general trees to binary trees: A general tree can be changed into an equiv

Explain all-pair shortest-paths problem, Explain All-pair shortest-paths pr...

Explain All-pair shortest-paths problem Given a weighted linked graph (undirected or directed), the all pairs shortest paths problem asks to find the distances (the lengths of

Red-black trees, A Red-Black Tree (RBT) is a type of Binary Search tree wit...

A Red-Black Tree (RBT) is a type of Binary Search tree with one extra bit of storage per node, i.e. its color that can either be red or black. Now the nodes can have any of the col

Array, how to define the size of array

how to define the size of array

Pest control program, PART- Pest Control Program Prepare a Pest Contro...

PART- Pest Control Program Prepare a Pest Control Program for the facility that will address the management of Rodents, Insects and Birds. Your Pest Control Program should

For loop, for (i = 0; i sequence of statements } Here, the loop e...

for (i = 0; i sequence of statements } Here, the loop executes n times. Thus, the sequence of statements also executes n times. Since we suppose the time complexity of th

General, whats the definition of ADT and data type?

whats the definition of ADT and data type?

Recursion, difference between recursion and iteration

difference between recursion and iteration

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd