| 9 | } *root = NULL; |
| 10 | |
| 11 | void Insert(int key) |
| 12 | { |
| 13 | struct Node *t = root; |
| 14 | struct Node *r, *p; |
| 15 | |
| 16 | if (root == NULL) |
| 17 | { |
| 18 | p = (struct Node *)malloc(sizeof(struct Node)); |
| 19 | p->data = key; |
| 20 | p->lchild = p->rchild = NULL; |
| 21 | root = p; |
| 22 | return; |
| 23 | } |
| 24 | while (t != NULL) |
| 25 | { |
| 26 | r = t; |
| 27 | if (key < t->data) |
| 28 | t = t->lchild; |
| 29 | else if (key > t->data) |
| 30 | t = t->rchild; |
| 31 | else |
| 32 | return; |
| 33 | } |
| 34 | p = (struct Node *)malloc(sizeof(struct Node)); |
| 35 | p->data = key; |
| 36 | p->lchild = p->rchild = NULL; |
| 37 | |
| 38 | if (key < r->data) |
| 39 | r->lchild = p; |
| 40 | else |
| 41 | r->rchild = p; |
| 42 | } |
| 43 | |
| 44 | void Inorder(struct Node *p) |
| 45 | { |
nothing calls this directly
no outgoing calls
no test coverage detected