SlideShare a Scribd company logo
1 of 15
Download to read offline
Binary Search Tree
Aakash Montheiro - 161702
Abhishek.L.R - 161704
Deelan Jostan Monthero - 161726
I Sem - M.C.A
Aloysius Institute Of Management &
Information Technology
What is …?
• A Binary tree is a non-linear data structure which is a collection of elements
called nodes.
• A Binary Search Tree (BST) is a Binary tree in which all the nodes follow the
below-mentioned properties :
The left sub-tree of a node has a key less than or equal to its parent node's key.
The right sub-tree of a node has a key greater than to its parent node's key.
• Thus, BST divides all its sub-trees into two segments;
 Left sub-tree
 Right sub-tree
Operations Performed in a BST:
Search − Searches an element in a tree.
Insert − Inserts an element in a tree.
Traversal :
Pre-order Traversal − Traverses a tree in a pre-order manner. [Root->Left->Right]
In-order Traversal − Traverses a tree in an in-order manner. [Left->Root->Right]
Post-order Traversal − Traverses a tree in a post-order manner.[Left->Right->Root]
Example:
Given : 37 ,24 ,45 ,20 ,29 ,41,52
37
24 45
20 29 41 52
Binary Tree v/s Binary Search Tree
Given : 37 ,45 ,24 ,29 ,41 ,20 ,24 ,52
24
37
24 45
20 29 41 52
37
24 45
20 29 41 52
37
24 45
20 29 41 52
Implementation:
• Creating the Structure
typedef struct Tree{
int Data;
struct Tree *Right;
struct Tree * Left;
}TREENODE;
Data *Right
*Left
Null Null
Implementation Contd..
class BSTree{
TREENODE *Root;
public:
BTree();//--Constructor
TREENODE *MakeTreeNode(int Num);
void InsertTreeNode(int Num);
void Preorder(TREENODE *Root);
void Postorder(TREENODE *Root);
void Inorder(TREENODE *Root);
TREENODE *GetRoot();
int TreeSearch(int Num);
};
Creating the Class:
Implementation Contd…
BTree::BTree()
{
Root=NULL;
}
TREENODE *BTree::MakeTreeNode(int Num)
{
TREENODE *New;
New=(TREENODE *)malloc(sizeof(TREENODE));
New->Data=Num;
New->Right=NULL;
New->Left=NULL;
return New;
}
TREENODE *BTree::GetRoot()
{
return Root;
}
Constructor
Getting the Root Node
Creating the Node
Implementation Contd…
void BTree::InsertTreeNode(int Num)
{
TREENODE *New,*Cur,*Prev;
Cur=Prev=Root;
New=MakeTreeNode(Num);
if(Root==NULL){
Root=New;
return;
}
Inserting a Element to a tree:
Implementation Contd…
Inserting a Element to a tree Contd:
while(Cur){
if(Num>Cur->Data){
Prev=Cur;
Cur=Cur->Right;
}else{
Prev=Cur;
Cur=Cur->Left;
}
}
if(Num>Prev->Data){
Prev->Right=New;
}else{
Prev->Left=New;
}
return;
}
Implementation Contd…
void BTree::Preorder(TREENODE *Root)
{
if(Root){
cout<<Root->Data<<"t""";
Preorder(Root->Left);
Preorder(Root->Right);
}
}
void BTree::Postorder(TREENODE *Root)
{
if(Root){
Postorder(Root->Left);
Postorder(Root->Right);
cout<<Root->Data<<"t";
}
}
void BTree::Inorder(TREENODE *Root)
{
if(Root){
Inorder(Root->Left);
cout<<Root->Data<<"t";
Inorder(Root->Right);
}
}
Pre-Order
In-Order
Post-Order
Traversing the Tree
int BTree::TreeSearch(int Num)
{
TREENODE *Cur;
Cur=Root;
while(Cur){
if(Num==Cur->Data){
return 1;
}else if(Num>Cur->Data){
Cur=Cur->Right;
}else{
Cur=Cur->Left;
}
}
}
Implementation Contd…
Searching the Element
Implementation Contd…
Inserting elements in Main Program cout<<"Enter the value of N : ";
cin>>N;
cout<<"Enter the elements n";
for(i=1;i<=N;i++){
cout<<"Enter the element A["<<i<<"] : ";
cin>>Num;
BT.InsertTreeNode(Num);
}
Declaration in Main Program
TREENODE *Root;
BTree BT;
Implementation Contd…
Root=BT.GetRoot();
cout<<"Pre-order traverse is : ";
BT.Preorder(Root);
cout<<"n";
break;
Traversing the Tree
Searching of Elements
cout<<"Enter the Search element : ";
cin>>Search;
Res=BT.TreeSearch(Search);
if(Res==1){
cout<<"Element "<<Search<<" Found...n";
}else{
cout<<"Element "<<Search<<" Not-found....n";
}
break;
Click here to download Source Code
Thank You
For
Your
Attention !
Any Question

More Related Content

Similar to bst-copy-171118141913.pdf

BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.pptplagcheck
 
data structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.pptdata structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.pptDharmannaRathod1
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureMeghaj Mallick
 
binarysearch-180319163432.pdf 11111111111
binarysearch-180319163432.pdf 11111111111binarysearch-180319163432.pdf 11111111111
binarysearch-180319163432.pdf 11111111111ArsalanAslam23
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary treeKrish_ver2
 
Binary search tree
Binary search treeBinary search tree
Binary search treeKousalya M
 
Binary Search Tree for design and analysis
Binary Search Tree for design and analysisBinary Search Tree for design and analysis
Binary Search Tree for design and analysisJavedKhan524377
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxasimshahzad8611
 
Binary Search Tree and AVL
Binary Search Tree and AVLBinary Search Tree and AVL
Binary Search Tree and AVLKatang Isip
 
Unit14_BinarySearchTree.ppt
Unit14_BinarySearchTree.pptUnit14_BinarySearchTree.ppt
Unit14_BinarySearchTree.pptplagcheck
 
Lecture 9 data structures and algorithms
Lecture 9 data structures and algorithmsLecture 9 data structures and algorithms
Lecture 9 data structures and algorithmsAakash deep Singhal
 
Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Getachew Ganfur
 

Similar to bst-copy-171118141913.pdf (20)

BinarySearchTrees.ppt
BinarySearchTrees.pptBinarySearchTrees.ppt
BinarySearchTrees.ppt
 
data structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.pptdata structure very BinarySearchTrees.ppt
data structure very BinarySearchTrees.ppt
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Unit iv data structure-converted
Unit  iv data structure-convertedUnit  iv data structure-converted
Unit iv data structure-converted
 
binarysearch-180319163432.pdf 11111111111
binarysearch-180319163432.pdf 11111111111binarysearch-180319163432.pdf 11111111111
binarysearch-180319163432.pdf 11111111111
 
Binary tree
Binary treeBinary tree
Binary tree
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Binary Search Tree for design and analysis
Binary Search Tree for design and analysisBinary Search Tree for design and analysis
Binary Search Tree for design and analysis
 
binary_trees2
binary_trees2binary_trees2
binary_trees2
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
 
Tree
TreeTree
Tree
 
Binary Search Tree and AVL
Binary Search Tree and AVLBinary Search Tree and AVL
Binary Search Tree and AVL
 
Unit14_BinarySearchTree.ppt
Unit14_BinarySearchTree.pptUnit14_BinarySearchTree.ppt
Unit14_BinarySearchTree.ppt
 
Binary searchtrees
Binary searchtreesBinary searchtrees
Binary searchtrees
 
8.binry search tree
8.binry search tree8.binry search tree
8.binry search tree
 
Lecture 9 data structures and algorithms
Lecture 9 data structures and algorithmsLecture 9 data structures and algorithms
Lecture 9 data structures and algorithms
 
Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 

Recently uploaded (20)

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 

bst-copy-171118141913.pdf

  • 1. Binary Search Tree Aakash Montheiro - 161702 Abhishek.L.R - 161704 Deelan Jostan Monthero - 161726 I Sem - M.C.A Aloysius Institute Of Management & Information Technology
  • 2. What is …? • A Binary tree is a non-linear data structure which is a collection of elements called nodes. • A Binary Search Tree (BST) is a Binary tree in which all the nodes follow the below-mentioned properties : The left sub-tree of a node has a key less than or equal to its parent node's key. The right sub-tree of a node has a key greater than to its parent node's key. • Thus, BST divides all its sub-trees into two segments;  Left sub-tree  Right sub-tree
  • 3. Operations Performed in a BST: Search − Searches an element in a tree. Insert − Inserts an element in a tree. Traversal : Pre-order Traversal − Traverses a tree in a pre-order manner. [Root->Left->Right] In-order Traversal − Traverses a tree in an in-order manner. [Left->Root->Right] Post-order Traversal − Traverses a tree in a post-order manner.[Left->Right->Root]
  • 4. Example: Given : 37 ,24 ,45 ,20 ,29 ,41,52 37 24 45 20 29 41 52
  • 5. Binary Tree v/s Binary Search Tree Given : 37 ,45 ,24 ,29 ,41 ,20 ,24 ,52 24 37 24 45 20 29 41 52 37 24 45 20 29 41 52 37 24 45 20 29 41 52
  • 6. Implementation: • Creating the Structure typedef struct Tree{ int Data; struct Tree *Right; struct Tree * Left; }TREENODE; Data *Right *Left Null Null
  • 7. Implementation Contd.. class BSTree{ TREENODE *Root; public: BTree();//--Constructor TREENODE *MakeTreeNode(int Num); void InsertTreeNode(int Num); void Preorder(TREENODE *Root); void Postorder(TREENODE *Root); void Inorder(TREENODE *Root); TREENODE *GetRoot(); int TreeSearch(int Num); }; Creating the Class:
  • 8. Implementation Contd… BTree::BTree() { Root=NULL; } TREENODE *BTree::MakeTreeNode(int Num) { TREENODE *New; New=(TREENODE *)malloc(sizeof(TREENODE)); New->Data=Num; New->Right=NULL; New->Left=NULL; return New; } TREENODE *BTree::GetRoot() { return Root; } Constructor Getting the Root Node Creating the Node
  • 9. Implementation Contd… void BTree::InsertTreeNode(int Num) { TREENODE *New,*Cur,*Prev; Cur=Prev=Root; New=MakeTreeNode(Num); if(Root==NULL){ Root=New; return; } Inserting a Element to a tree:
  • 10. Implementation Contd… Inserting a Element to a tree Contd: while(Cur){ if(Num>Cur->Data){ Prev=Cur; Cur=Cur->Right; }else{ Prev=Cur; Cur=Cur->Left; } } if(Num>Prev->Data){ Prev->Right=New; }else{ Prev->Left=New; } return; }
  • 11. Implementation Contd… void BTree::Preorder(TREENODE *Root) { if(Root){ cout<<Root->Data<<"t"""; Preorder(Root->Left); Preorder(Root->Right); } } void BTree::Postorder(TREENODE *Root) { if(Root){ Postorder(Root->Left); Postorder(Root->Right); cout<<Root->Data<<"t"; } } void BTree::Inorder(TREENODE *Root) { if(Root){ Inorder(Root->Left); cout<<Root->Data<<"t"; Inorder(Root->Right); } } Pre-Order In-Order Post-Order Traversing the Tree
  • 12. int BTree::TreeSearch(int Num) { TREENODE *Cur; Cur=Root; while(Cur){ if(Num==Cur->Data){ return 1; }else if(Num>Cur->Data){ Cur=Cur->Right; }else{ Cur=Cur->Left; } } } Implementation Contd… Searching the Element
  • 13. Implementation Contd… Inserting elements in Main Program cout<<"Enter the value of N : "; cin>>N; cout<<"Enter the elements n"; for(i=1;i<=N;i++){ cout<<"Enter the element A["<<i<<"] : "; cin>>Num; BT.InsertTreeNode(Num); } Declaration in Main Program TREENODE *Root; BTree BT;
  • 14. Implementation Contd… Root=BT.GetRoot(); cout<<"Pre-order traverse is : "; BT.Preorder(Root); cout<<"n"; break; Traversing the Tree Searching of Elements cout<<"Enter the Search element : "; cin>>Search; Res=BT.TreeSearch(Search); if(Res==1){ cout<<"Element "<<Search<<" Found...n"; }else{ cout<<"Element "<<Search<<" Not-found....n"; } break; Click here to download Source Code