Graph Tutorial
1.Create_tree
- Beginer tutorial in Graph
- tutorial-on-graph-theory
Depth First search Traversal
1.Create_tree
#include<iostream>
#define size 3
using namespace std;
class node
{
public:
int data;
node *left;
node *right;
};
class tree
{
public:
node *root;
tree();
void create_tree(int data);
void inorder_traverse(node *s);
void print_data();
};
tree::tree()
{
root=NULL;
}
void tree::create_tree(int data)
{
node *temp = new node;
temp->data = data;
temp->left =NULL;
temp->right =NULL;
if(root ==NULL)
root =temp;
else
{
node *p =root;
node *trail =NULL;
while(p!=NULL)
{
root=p;
if(p->data > data)
{
p =p->left;
}
else
{
p=p->right;
}
}
if(root->data > data)
{
root->left =temp;
}
else
{
root->right = temp;
}
}
}
void tree::inorder_traverse(node *s)
{
if(s)
{
inorder_traverse(s->left);
cout<<s->data<<" ";
inorder_traverse(s->right);
}
}
void tree::print_data()
{
inorder_traverse(root);
}
int main()
{
int data;
tree t;
for(int i=0;i<3;i++)
{
cout<<"Enter data";
cin>>data;
t.create_tree(data);
}
cout<<"inorder: traverse :"<<endl;
t.print_data();
return 0;
}
#include<iostream>
using namespace std;
class node
{
public:
int data;
node *left;
node *right;
};
class tree
{
public:
node *root;
tree();
void create_tree(int data);
void print_tree();
void tree_level_order_traverse(node *root);
};
tree::tree()
{
root =NULL;
}
void tree::create_tree(int data)
{
node *temp = new node;
temp->data = data;
temp->left = NULL;
temp->right =NULL;
if(root==NULL)
root=temp;
else
{
node *p=root;
node *trail =NULL;
while(p!=NULL)
{
trail=p;
if(p->data > data)
p=p->left;
else
p=p->right;
}
if(trail->data > data)
trail->left = temp;
else
trail->right = temp;
}
}
void tree::tree_level_order_traverse(node *root)
{
node *data_store[10] = { (node*)0} ;
int size=0;
int follow_variable=0;
while(root)
{
cout<<root->data<<" :";
if(root->left)
data_store[size++]=root->left;
if(root->right)
data_store[size++]=root->right;
root=data_store[follow_variable++];
}
}
void tree::print_tree()
{
tree_level_order_traverse(root);
}
int main()
{
tree t;
for(int i=0;i<8;i++)
t.create_tree(i);
cout<<"create successful"<<endl;
t.print_tree();
return 0;
}
#include<iostream>
using namespace std;
class node
{
public:
int data;
node *left;
node *right;
}
class tree
{
public:
node *root;
tree();
void create_tree(int data);
};
tree::tree()
{
root =NULL;
}
void tree::create_tree(int data)
{
node *temp= new node;
temp->data = data;
temp->left =NULL;
temp->right =NULL;
node *p=root;
while(p!=NULL)
{
root =p;
if(p->data > data)
p=p->left;
else
p=p->right;
}
if(root->data > data)
root->left = temp;
else
root->right = temp;
}
Find_Max_Element_without_Recursion
template<class T>
int tree<T>::find_max_element(node *root)
{
node *queue[10]= {(node*)0};
node *p=root;
int data;
int size=0;
int follow_variable =0;
int max=0;
while(p!=NULL)
{
if(max < p->data)
max = p->data;
if(p->left)
queue[size++] = p->left;
if(p->right)
queue[size++] = p->right;
p = queue[follow_variable++];
}
cout<<"the max data :"<<max<<endl;
return max;
Find_Max_Element_with_Recursion
int tree<T>::find_max_element(node *root)
{
int root_value;
int left;
int right;
int max =0;
if(root!=NULL)
{
root_value = root->data;
left = find_max_element(root->left);
right = find_max_element(root->right);
if(right > left)
max=right;
else
max=left;
if(root_value > max)
max=root_value;
}
return max;
Reverse_level_order_traverse
void tree::reverse_level_order(node *root)
{
node *temp_storage[10]= {(node *)0};
int size =0;
int flow_variable =0;
while(root)
{
cout<<" "<<root->data;
if(root->right)
{
temp_storage[size++]=root->right;
}
if(root->left)
{
temp_storage[size++] = root->left;
}
root=temp_storage[flow_variable++];
}
}
I have to search sites with relevant information on given topic ExcelR Machine Learning Courses and provide them to teacher our opinion and the article.
ReplyDeletemmorpg oyunlar
ReplyDeleteinstagram takipçi satın al
TİKTOK JETON HİLESİ
Tiktok jeton hilesi
antalya saç ekimi
referans kimliği nedir
İNSTAGRAM TAKİPÇİ SATIN AL
Metin2 pvp serverlar
instagram takipçi satın al
instagram takipçi satın al
YENİ PERDE MODELLERİ
ReplyDeletesms onay
mobil ödeme bozdurma
nft nasıl alınır
ankara evden eve nakliyat
Trafik sigortası
dedektör
web sitesi kurma
aşk kitapları
SMM PANEL
ReplyDeleteSmm Panel
iş ilanları
İnstagram takipçi satın al
Https://www.hirdavatciburada.com/
beyazesyateknikservisi.com.tr
SERVİS
TİKTOK PARA HİLESİ
Good content. You write beautiful things.
ReplyDeletekorsan taksi
hacklink
sportsbet
taksi
mrbahis
vbet
mrbahis
vbet
hacklink
Good text Write good content success. Thank you
ReplyDeletekibris bahis siteleri
poker siteleri
kralbet
betmatik
mobil ödeme bahis
betpark
tipobet
bonus veren siteler
Önemli giriş adreslerine buradan ulaşabilirsiniz.
ReplyDeletebetturkey giriş
betpark giriş
SF3FS3
manisa
ReplyDeletemaraş
mardin
marmaris
mersin
WİQMO
kağıthane
ReplyDeletemuğla
tuzla
etiler
maltepe
6MF7
https://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
4DJV
شركة عزل اسطح gz5oNOj5Ps
ReplyDelete