This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: COMP 250 Winter 2010 20 - binary search trees 1 March 3, 2010 (last modified 4/14) Binary Search Trees Last lecture we defined a binary tree ADT which contained an element at each node, along with a left and right child. (We briefly considered a implementation of this in Java, though this implementation was not the emphasis.) Let’s now consider a specific type of binary tree in which there happens to be an ordering defined on the set of elements at each node. For example, if the element is a real number (or an integer), then there is an obvious order. Or if the element is a string, then again there is an obvious ordering (namely the dictionary ordering, also known as “lexicographic ordering”). The ordering on the elements induces an ordering on the nodes – we can say that one node is less than or greater than another node. By this, we simply mean that the elements at the one node is less than greater than the element at the other node. A binary search tree is a binary tree with comparable elements (i.e. the ordering relation < ), such that for any node [modified 4/14]: • all nodes in the left subtree are less than the node • all nodes in the right subtree are greater than the node We will refer to the element stored at binary search tree as a...
View Full Document