Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How would you print out the data in a binary tree, level by
level, starting at the top?

Answer Posted / hardik

To Print data in binary tree..a recursive function should be
used here post for postorder, in for inorder & pre for
rpeorder...


void post(struct node *temp)
{
if(temp->lptr!=NULL)
post(temp->lptr);
if(temp->rptr!=NULL)
post(temp->rptr);
if(temp!=NULL)
printf("%d\t%s\t%d\n",temp->rollno,temp->name,temp->marks);
}

void pre(struct node *temp)
{
if(temp!=NULL)
printf("%d\t%s\t%d\n",temp->rollno,temp->name,temp->marks);
if(temp->lptr!=NULL)
pre(temp->lptr);
if(temp->rptr!=NULL)
pre(temp->rptr);
}

void in(struct node *temp)
{
if(temp->lptr!=NULL)
in(temp->lptr);
if(temp!=NULL)
printf("%d\t%s\t%d\n",temp->rollno,temp->name,temp->marks);
if(temp->rptr!=NULL)
in(temp->rptr);
}

Is This Answer Correct ?    2 Yes 27 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between c &c++?

1082


How can I handle floating-point exceptions gracefully?

1106


Why isnt there a numbered, multi-level break statement to break out

994


What are control structures? What are the different types?

1036


How do you define CONSTANT in C?

1209


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

1127


What are Macros? What are its advantages and disadvantages?

1091


Describe wild pointers in c?

1060


List the different types of c tokens?

1009


What are the 4 data types?

960


What is header file in c?

1019


What are the features of c language?

1021


What does the c in ctime mean?

1015


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

2694


What is meant by int main ()?

1154