How will inorder, preorder and postorder traversals print
the elements of a tree?

Answer Posted / soma gidugu

void inorder(node * root)
{
if(root!= NULL)
{
inorder(root->leftchild);
printf("%d ",root->data);
inorder(root->rightchild);
}
else
return;

}

void postorder(node * root)
{
if(root!= NULL)
{
postorder(root->leftchild);
postorder(root->rightchild);
printf("%d ",root->data);
}
else
return;
}

void preorder(node * root)
{
if(root!= NULL)
{
printf("%d ",root->data);
preorder(root->leftchild);
preorder(root->rightchild);
}
else
return;

}

Is This Answer Correct ?    13 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are binary search and fibonacci search?

511


How do you declare An array of three pointers to chars

508


Why do we use linked lists?

479


Can you use Bubble Sort To sort the number of elements.

502


What’s the difference between enumeration and iterator interfaces?

512






State the difference between queues and linked lists?

540


Define primary data structures?

582


What are the advantages of sorting?

523


Can arraylist store objects?

457


Can the double-checked locking fail on a single processor system?

565


What is data structure explain different types of data structures with examples?

506


Can you list out the areas in which data structures are applied extensively?

627


What's the difference between a hashtable and a hashmap?

456


Is data structure a data type?

503


What is the difference between collection and collections?

539