Dsa Lab 11 064
Dsa Lab 11 064
Dsa Lab 11 064
ALGORITHMS
WARISHA MALIK
064 BSCS
TASK 1
INPUT
#include<iostream>
using namespace std;
class node{
public:
int data;
node* left = NULL;
node* right = NULL;
};
class bt
{ public:
// Insert data.
if(value<root->data){
if(root->left == NULL)
{
root->left = Insert(root->left, value);
}
else{
if (nodee->data == key)
return true;
bool res1 = search_specific(nodee->left, key);
if(res1) return true;
return res2;
}
int findMin(node* root)
{
//code
if(root==NULL)
{
return INT_MAX;
}
int res=root->data;
int left=findMin(root->left);
int right=findMin(root->right);
if(left<res)
{
res=left;
}
if(right<res)
{
res=right;
}
return res;
}
};
// Driver code
int main()
{
node *root = NULL;
bt b;
int num,value;
cout<<"\n Enter the number of nodes: ";
cin>>num;
cout<<"Enter the value of nodes : ";
cin>>value;
root = b.Insert(root,value);
for(int i =0;i<num-1;i++){
cout<<"\n Enter the value of nodes : ";
cin>>value;
b.Insert(root,value);
}
cout<<"\n Displaying data in tree : "<<endl;
b.displayin(root);
OUTPUT