Binary search tree: find: Difference between revisions

From Algowiki
Jump to navigation Jump to search
(Created page with ":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)")
 
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]]

Revision as of 22:05, 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)