10 struct node
*aux1
, *aux2
;
11 struct node
*splay(struct node
*n
, int val
){
12 struct node N
, *l
, *r
;
19 if( n
->l
->val
> val
){
29 }else if( n
->val
< val
){
31 if( n
->r
->val
< val
){
50 void split(struct node
*T
, int k
){
51 if( !T
) { S1
= S2
= NULL
; return ; }
52 struct node
*aux
= splay(T
,k
);
63 struct node
*join(struct node
*T1
, struct node
*T2
){
64 if( T1
== NULL
) return T2
;
65 if( T2
== NULL
) return T1
;
66 T1
= splay(T1
, INT_MAX
);
70 struct node
*insert(struct node
*T
, int k
){
71 struct node
*aux
= new node
;
78 struct node
*deleteval(struct node
*T
, int k
){
79 if( T
== NULL
) return T
;
90 void dfs(struct node
* r
){
91 if( r
== NULL
) return;
92 printf(" %i ", r
->val
);
104 printf("Introduzca números para el árbol ( 1 x insertar... 2 x buscar, 0 x borrar:\n");
108 if( i
== 1 )root
= insert(root
, k
);
110 root
= splay( root
, k
);
111 if( root
&& root
->val
== k
) printf("Si esta!!!\n");
112 else printf("No esta!!!\n");
114 else root
= deleteval(root
, k
);