Binary search tree: remove: Difference between revisions
Jump to navigation
Jump to search
(Created page with "TREE-DELETE(T,z) :if left[z] = NULL or right[z] = NULL ::then y = z ::else y = TREE-SUCCESSOR(z) :if left[y] ≠ NULL ::then x = left[y] ::else x = right[y] :if x ≠ NULL ::t...") |
No edit summary |
||
Line 17: | Line 17: | ||
:::copy y's satellite data into z | :::copy y's satellite data into z | ||
:return y | :return y | ||
[[Category:Binary Search Tree]] |
Revision as of 22:03, 19 September 2014
TREE-DELETE(T,z)
- if left[z] = NULL or right[z] = NULL
- then y = z
- else y = TREE-SUCCESSOR(z)
- if left[y] ≠ NULL
- then x = left[y]
- else x = right[y]
- if x ≠ NULL
- then p[x] = p [y]
- if p[y] = NULL
- then root[T] = x
- else if y = left[p[y]]
- then left[p[y]] = x
- else right[p[y]] = x
- if y ≠ z
- then key[z] = key[y]
- copy y's satellite data into z
- then key[z] = key[y]
- return y