typedef struct node

2 downloads 139 Views 69KB Size Report
6. 5. 7. 4. 2. 9. 8. Root. Leaves ... bool search(node* root, int val). { if root is NULL return false. if root->n is
Tree 1 2

3

4 8

5 9

6

7

Root 1 2

3

4 8

5 9

6

Leaves

7

Binary Tree 33 99

88

77

22

11

66

55

typedef struct node { int n; struct node* left; struct node* right; } node;

Binary Search Tree 55 33

77

33 22

22

77 44

44

66

66

88

88

bool search(node* root, int val) { if root is NULL return false. if root->n is val return true. if val is less than root->n search left child if val is greater than root->n search right child }

Suggest Documents