Data Structures and Algorithms Lecture Notes

28 March 2011 • Binary Search Trees


Outline

Tree Performance

Binary Trees and Order

Binary Search Trees

Example

Binary Search Tree Member

Binary Search Tree Add

Removing Nodes.

Removing Nodes..

Binary Search Tree Remove

Node remove(V v, Node root)

 if (root != null)
   if v < root.value
    root.left = remove(v, root.left)
   else if root.value < v
    root.right = remove(v, root.right)
   else
    if root.left != null
     root.left, root.value = extractMax(root.left)
    else if root.right != null
     root.right, root.value = extractMin(root.right)
    else
     root = null

 return root

Performance

Summary

References


This page last modified on 2010 November 16.

Creative
    Commons License