Skip to content

Instantly share code, notes, and snippets.

@ahmedahamid
Last active September 20, 2015 05:10
Show Gist options
  • Save ahmedahamid/ed391e9a0d3283811281 to your computer and use it in GitHub Desktop.
Save ahmedahamid/ed391e9a0d3283811281 to your computer and use it in GitHub Desktop.
Tricky pointer basics explained | Recursive implementation of binary search
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