-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·60 lines (52 loc) · 1.2 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<iostream>
#include"Noeud.h"
using namespace std;
Noeud creation(){
int* cle=NULL;
Noeud arbre_vide(cle);
return arbre_vide;
}
void verification(Noeud arbre){
if (arbre.Get_cle() == NULL and arbre.Get_fg() == NULL and arbre.Get_fd() == NULL) {
cout<< "L'arbre est vide" <<endl;
}
else {
cout<< "L'arbre n'est pas vide" <<endl;
}
}
Noeud* recherche(int* r,Noeud p){
Noeud* pN = &p;
Noeud N(NULL);
bool t = false;
while(t==false){
N=*pN;
if(*(N.Get_cle())==*r){
t=true;
cout<<"Le noeud qu'on recherche existe et a été atteint."<<endl;
return pN;
} else if((*(N.Get_cle())<*r)and(N.Get_fg()!=NULL)){
pN=N.Get_fg();
} else if((*(N.Get_cle())>*r)and(N.Get_fd()!=NULL)){
pN=N.Get_fd();
} else {
t=true;
cout<<"Le noeud qu'on recherche n'existe pas, le plus proche a été renvoye."<<endl;
return pN;
}
}
}
void insertion(int* cle, Noeud N){
Noeud Noeud_pere=*recherche(cle,N);
if(*cle<*Noeud_pere.Get_cle()){
Noeud_pere.new_ng(cle);
}
else{
Noeud_pere.new_nd(cle);
}
}
int main(){
Noeud racine=creation();
int a=8;
Noeud* fin= recherche(&a,racine);
cout<<fin<<endl;
}