Binary search tree: find: Difference between revisions

From Algowiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
:::then return TREE-SEARCH(left[x], k)
:::then return TREE-SEARCH(left[x], k)
::else return TREE-SEARCH(right[x], k)
::else return TREE-SEARCH(right[x], k)
[[Category:Binary Search Tree]]
[[Category:Binary_Search_Tree]]

Revision as of 22:35, 19 September 2014

TREE-SEARCH (x, k)
if x= NIL or k = key[x]
then return x
if k < key[x]
then return TREE-SEARCH(left[x], k)
else return TREE-SEARCH(right[x], k)