This preview shows page 1. Sign up to view the full content.
1
Binary Search Tree
•
A
binary search tree
(BST), is a binary tree where for
every
node
n
in the tree:
n
's value is
greater
than all the values in its
left
subtree.
n
's value is
less
than all the values in its
right
subtree.
both
n
's left and right subtrees are binary search trees.
2
4
1
5
3
Binary Search Tree
•
Problem
:
How many possible BSTs containing
This is the end of the preview. Sign up
to
access the rest of the document.
Unformatted text preview: values 1, 2, and 3 have degenerate structure (i.e., each node in the BST has at most one child)? • Solution : 3! ways to order 1, 2, and 3 for insertion 1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1 There are 4 degenerate BSTs possible. 2 3 1 2 3 1 1 2 3 1 3 2 3 1 2 3 2 1...
View
Full
Document
This document was uploaded on 12/24/2011.
 Spring '09
 Binary Search

Click to edit the document details