| 22 | } |
| 23 | } |
| 24 | int search(struct node *root, int key){ |
| 25 | struct node *prev = NULL; |
| 26 | while(root!=NULL){ |
| 27 | prev = root; |
| 28 | if(key==root->data){ |
| 29 | printf("Cannot insert %d, already in BST", key); |
| 30 | return 1; |
| 31 | } |
| 32 | else if(key<root->data){ |
| 33 | root = root->left; |
| 34 | } |
| 35 | else{ |
| 36 | root = root->right; |
| 37 | } |
| 38 | } |
| 39 | return 0; |
| 40 | } |
| 41 | struct node *insert(struct node *node, int key) { |
| 42 | if(search(node,key)==0){ |
| 43 |
no outgoing calls
no test coverage detected