Last active
September 20, 2015 05:10
-
-
Save ahmedahamid/ed391e9a0d3283811281 to your computer and use it in GitHub Desktop.
Tricky pointer basics explained | Recursive implementation of binary search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tree_node* binary_search(tree_node* n, int value) | |
{ | |
if (n == NULL) | |
{ | |
return NULL; | |
} | |
if (value == n->data) | |
{ | |
return n; | |
} | |
if (value < n->data) | |
{ | |
return binary_search(n->left, value); | |
} | |
// else ... | |
return binary_search(n->right, value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment