SlideShare a Scribd company logo
1 of 4
10
Solution
#include<iostream.h>
#include<conio.h>
#include<process.h>
struct tree_node
{
tree_node *left;
tree_node *right;
int data;
} ;
class bst
{
tree_node *root;
public:
bst()
{
root=NULL;
}
int isempty()
{
return(root==NULL);
}
void insert(int item);
void inordertrav();
void inorder(tree_node *);
void postordertrav();
void postorder(tree_node *);
void preordertrav();
void preorder(tree_node *);
};
void bst::insert(int item)
{
tree_node *p=new tree_node;
tree_node *parent;
p->data=item;
p->left=NULL;
p->right=NULL;
parent=NULL;
if(isempty())
root=p;
else
{
tree_node *ptr;
ptr=root;
while(ptr!=NULL)
{
parent=ptr;
if(item>ptr->data)
ptr=ptr->right;
else
ptr=ptr->left;
}
if(item<parent->data)
parent->left=p;
else
parent->right=p;
}
}
void bst::inordertrav()
{
inorder(root);
}
void bst::inorder(tree_node *ptr)
{
if(ptr!=NULL)
{
inorder(ptr->left);
cout<<" "<<ptr->data<<" ";
inorder(ptr->right);
}
}
void bst::postordertrav()
{
postorder(root);
}
void bst::postorder(tree_node *ptr)
{
if(ptr!=NULL)
{
postorder(ptr->left);
postorder(ptr->right);
cout<<" "<<ptr->data<<" ";
}
}
void bst::preordertrav()
{
preorder(root);
}
void bst::preorder(tree_node *ptr)
{
if(ptr!=NULL)
{
cout<<" "<<ptr->data<<" ";
preorder(ptr->left);
preorder(ptr->right);
}
}
void main()
{
bst b;
b.insert(52);
b.insert(25);
b.insert(50);
b.insert(15);
b.insert(40);
b.insert(45);
b.insert(20); cout<<"inorder"<<endl;
b.inordertrav();
cout<<endl<<"postorder"<<endl;
b.postordertrav();
cout<<endl<<"preorder"<<endl;
b.preordertrav();
getch();
}
10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx

More Related Content

Similar to 10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx

Tree Traversals A tree traversal is the process of visiting.pdf
Tree Traversals A tree traversal is the process of visiting.pdfTree Traversals A tree traversal is the process of visiting.pdf
Tree Traversals A tree traversal is the process of visiting.pdfajayadinathcomputers
 
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdframbagra74
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfsooryasalini
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementationsRex Mwamba
 
How to do the main method for this programBinaryNode.javapublic.pdf
How to do the main method for this programBinaryNode.javapublic.pdfHow to do the main method for this programBinaryNode.javapublic.pdf
How to do the main method for this programBinaryNode.javapublic.pdffeelingcomputors
 
Help to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfHelp to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfcontact32
 
MAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdfMAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdfadityastores21
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfanwarsadath111
 
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdfAssignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdfFootageetoffe16
 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfillyasraja7
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfshaktisinhgandhinaga
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfalphaagenciesindia
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureZarghamullahShah
 
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfObjective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfsivakumar19831
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
I have C++ question that I do not know how to do, Can you teach me t.pdf
I have C++ question that I do not know how to do, Can you teach me t.pdfI have C++ question that I do not know how to do, Can you teach me t.pdf
I have C++ question that I do not know how to do, Can you teach me t.pdffasttrackscardecors
 

Similar to 10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx (20)

Tree Traversals A tree traversal is the process of visiting.pdf
Tree Traversals A tree traversal is the process of visiting.pdfTree Traversals A tree traversal is the process of visiting.pdf
Tree Traversals A tree traversal is the process of visiting.pdf
 
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdf
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementations
 
How to do the main method for this programBinaryNode.javapublic.pdf
How to do the main method for this programBinaryNode.javapublic.pdfHow to do the main method for this programBinaryNode.javapublic.pdf
How to do the main method for this programBinaryNode.javapublic.pdf
 
Help to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdfHelp to implement delete_node get_succ get_pred walk and.pdf
Help to implement delete_node get_succ get_pred walk and.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
MAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdfMAINCPP include ltiostreamgt include ltstringgt u.pdf
MAINCPP include ltiostreamgt include ltstringgt u.pdf
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
 
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdfAssignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
 
Given the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdfGiven the following codepackage data1;import java.util.;p.pdf
Given the following codepackage data1;import java.util.;p.pdf
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdfimport java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
import java.util.Scanner;class BinaryNode{     BinaryNode left.pdf
 
C Programming Homework Help
C Programming Homework HelpC Programming Homework Help
C Programming Homework Help
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structure
 
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfObjective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
I have C++ question that I do not know how to do, Can you teach me t.pdf
I have C++ question that I do not know how to do, Can you teach me t.pdfI have C++ question that I do not know how to do, Can you teach me t.pdf
I have C++ question that I do not know how to do, Can you teach me t.pdf
 

More from todd991

14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docx14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docxtodd991
 
14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docx14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docxtodd991
 
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docxtodd991
 
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docxtodd991
 
10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docx10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docxtodd991
 
1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docx1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docxtodd991
 
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docxtodd991
 
1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docx1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docxtodd991
 
1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docx1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docxtodd991
 
1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docx1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docxtodd991
 
1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docx1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docxtodd991
 
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docxtodd991
 
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docxtodd991
 
1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docx1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docxtodd991
 
1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docx1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docxtodd991
 
1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docx1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docxtodd991
 
1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docx1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docxtodd991
 
1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docx1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docxtodd991
 
1- Return the names- IDS- and average salary of the top 10 employees w.docx
1- Return the names- IDS- and average salary of the top 10 employees w.docx1- Return the names- IDS- and average salary of the top 10 employees w.docx
1- Return the names- IDS- and average salary of the top 10 employees w.docxtodd991
 
1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docx1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docxtodd991
 

More from todd991 (20)

14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docx14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
14- Which of the following is the correct name for NalICO- A- Sodiuns.docx
 
14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docx14 Income tax is estimated at 40- of income- What factors other than e.docx
14 Income tax is estimated at 40- of income- What factors other than e.docx
 
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
12-19 Notes Compare and contrast the Hubble Space Telescope with James.docx
 
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
12-5 Distribution of Cash Upon Liquidation Manley and Singh are partne.docx
 
10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docx10- Consider the following data structure used for implementing a link.docx
10- Consider the following data structure used for implementing a link.docx
 
1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docx1-What are the consequences of long term unemployment- 2-Should the go.docx
1-What are the consequences of long term unemployment- 2-Should the go.docx
 
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx1-What is the conjugate base of H2C2O4-  2-Which of the following acid.docx
1-What is the conjugate base of H2C2O4- 2-Which of the following acid.docx
 
1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docx1-The fund financial statements for governmental funds should include.docx
1-The fund financial statements for governmental funds should include.docx
 
1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docx1-To a young researcher- what are the advantages of using the method o.docx
1-To a young researcher- what are the advantages of using the method o.docx
 
1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docx1-The party to receive a distribution of principal from an estate is l.docx
1-The party to receive a distribution of principal from an estate is l.docx
 
1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docx1-Consider an organization with which you have been affiliated as an e.docx
1-Consider an organization with which you have been affiliated as an e.docx
 
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
1-Astronomers estimate that a low-mass red dwarf star like Proxima Cen.docx
 
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
1-a Which of TCP or UDP is connection-less- Which of TCP or UDP is con.docx
 
1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docx1- You align 2 lenses together with known focal lengths fi and fa- The.docx
1- You align 2 lenses together with known focal lengths fi and fa- The.docx
 
1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docx1- What were some of the major work published by Thomas Maithus- emplo.docx
1- What were some of the major work published by Thomas Maithus- emplo.docx
 
1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docx1- What are the advantages and disadvantages of each of sociologys mai.docx
1- What are the advantages and disadvantages of each of sociologys mai.docx
 
1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docx1- What are the three fundamental elements of an effective security pr.docx
1- What are the three fundamental elements of an effective security pr.docx
 
1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docx1- What are the various theories that we use to explain why people com.docx
1- What are the various theories that we use to explain why people com.docx
 
1- Return the names- IDS- and average salary of the top 10 employees w.docx
1- Return the names- IDS- and average salary of the top 10 employees w.docx1- Return the names- IDS- and average salary of the top 10 employees w.docx
1- Return the names- IDS- and average salary of the top 10 employees w.docx
 
1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docx1- Research has shown that a- homogeneous groups are more creative tha.docx
1- Research has shown that a- homogeneous groups are more creative tha.docx
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

10 Solution#include-iostream-h- #include-conio-h- #include-process-h-.docx

  • 1. 10 Solution #include<iostream.h> #include<conio.h> #include<process.h> struct tree_node { tree_node *left; tree_node *right; int data; } ; class bst { tree_node *root; public: bst() { root=NULL; } int isempty() { return(root==NULL); } void insert(int item); void inordertrav(); void inorder(tree_node *); void postordertrav(); void postorder(tree_node *); void preordertrav(); void preorder(tree_node *); }; void bst::insert(int item)
  • 2. { tree_node *p=new tree_node; tree_node *parent; p->data=item; p->left=NULL; p->right=NULL; parent=NULL; if(isempty()) root=p; else { tree_node *ptr; ptr=root; while(ptr!=NULL) { parent=ptr; if(item>ptr->data) ptr=ptr->right; else ptr=ptr->left; } if(item<parent->data) parent->left=p; else parent->right=p; } } void bst::inordertrav() { inorder(root); } void bst::inorder(tree_node *ptr) { if(ptr!=NULL) { inorder(ptr->left); cout<<" "<<ptr->data<<" "; inorder(ptr->right); } } void bst::postordertrav() { postorder(root); } void bst::postorder(tree_node *ptr) {
  • 3. if(ptr!=NULL) { postorder(ptr->left); postorder(ptr->right); cout<<" "<<ptr->data<<" "; } } void bst::preordertrav() { preorder(root); } void bst::preorder(tree_node *ptr) { if(ptr!=NULL) { cout<<" "<<ptr->data<<" "; preorder(ptr->left); preorder(ptr->right); } } void main() { bst b; b.insert(52); b.insert(25); b.insert(50); b.insert(15); b.insert(40); b.insert(45); b.insert(20); cout<<"inorder"<<endl; b.inordertrav(); cout<<endl<<"postorder"<<endl; b.postordertrav(); cout<<endl<<"preorder"<<endl; b.preordertrav(); getch(); }