-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.c
More file actions
63 lines (42 loc) · 746 Bytes
/
Test.c
File metadata and controls
63 lines (42 loc) · 746 Bytes
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
61
62
63
#include <stdio.h>
#include <stdlib.h>
#define item int
typedef struct bintree
{
item d;
struct bintree *l;
struct bintree *r;
} tree;
#include "binTreeSim.h"
void insertBST(tree **rootp,item z)
{
if(*rootp)
{
if(z<(*rootp)->d)
insertBST(&((*rootp)->l),z);
else
insertBST(&((*rootp)->r),z);
}
else
{
*rootp=(tree *)malloc(sizeof(tree));
(*rootp)->d=z;
(*rootp)->l=(*rootp)->r=NULL;
}
}
main()
{
int i;
tree *bst=NULL;
insertBST(&bst,50);
init(&bst);
printf("All ok__press any key to insert random nos...\n");
//setopfmt("%5d");
// setopfmt("%0x");
while(getch()!=27)
{
redraw();
insertBST(&bst,rand()%100);
}
getchar();
}