Binary Search Tree Operations




CS146

Chris Pollett

Apr 9, 2014

Outline

Introduction

Querying a BST

Example Search

Example of Binary Search

ITERATIVE-TREE-SEARCH(x,k)

Minimum and Maximum

Successor

Predecessor and Run-times

Theorem. The dynamic set operations SEARCH, MINIMUM, MAXIMUM, SUCCESSOR, and PREDECESSOR can be implemented so that each one runs in `O(h)` time on a BST of height `h`.

Insertion

Example Insert

Example of inserting into a BST

Deletion

Example Illustrating the Different Cases

Three BST Delete Cases

Transplanting Trees

Delete Pseudo-code