View difference between Paste ID: q10MVpw7 and QctBi8fQ
SHOW: | | - or go back to the newest paste.
1
#include<iostream>
2
#include<cmath>
3
using namespace std;
4
5
struct node
6
{
7
  int T;
8
  node *LEFT;
9
  node *RIGHT;
10
};
11
12
void search (int k, node *leaf)
13
{
14
  if(leaf!=NULL)
15
  {
16
    if(k==leaf->T)
17
      return leaf;
18
    if(k<leaf->T)
19
      return search(k, leaf->left);
20
    else
21
      return search(k, leaf->right);
22
  }
23
  else return NULL;
24
}
25
26
void insert( node *&root, int k ){
27
	if (root!= NULL){
28
		insert (root, k);
29
	}
30
	else{
31
		root = new node;
32
		root -> T = k;
33
		root->LEFT = NULL;
34
		root->RIGHT = NULL;
35
	}
36
	}
37
38
int main(){
39
	node*root=NULL;
40
	int k;
41
42
	insert(root,99);
43
44
	return 0;
45
46
}