Lab Manual # 11: Title: Binary Tree Implementation
Lab Manual # 11: Title: Binary Tree Implementation
Lab Manual # 11: Title: Binary Tree Implementation
Lab Manual # 11
Lab Submission[10] 0 1 2 3 4 5
Completeness & Correctness
Required Conclusion & Results
No of Checks
SUB TOTAL
TOTAL SCORE
Course Instructor
// A function creating new node of the tree and assigning the data.
node* CreateNode(int data)
{
node *newnode = new node;
newnode->data = data;
newnode->left = NULL;
newnode->right = NULL;
return newnode;
}
int main()
{
char ch;
int n, i, a[20]={89, 53, 95, 1, 9, 67, 72, 66, 75, 77, 18, 24, 35, 90, 38, 41, 49, 81, 27, 97};
node *root = new node;
root = NULL;
Search(root, n);
return 0;
}
#include <iostream>
class BST
{
int data;
public:
// Default constructor.
BST();
// Parameterized constructor.
BST(int);
// Insert function.
// Inorder traversal.
void Inorder(BST*);
};
: data(0)
, left(NULL)
, right(NULL)
{
}
if (!root)
// Insert data.
else
return root;
}
if (!root) {
return;
Inorder(root->left);
Inorder(root->right);
}
// Driver code
int main()
{
b.Insert(root, 03);
b.Insert(root, 16);
b.Insert(root, 93);
b.Insert(root, 22);
b.Insert(root, 450);
b.Insert(root, 27);
b.Inorder(root);
cout<<"\n\t\tMuhammad Usama Saghar 2019-cpe-27";
return 0;
}