lecture20

lecture20 - COMP 250 Winter 2010 20 - binary search trees 1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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

This note was uploaded on 09/25/2011 for the course COMP 250 taught by Professor Blanchette during the Spring '08 term at McGill.

Page1 / 4

lecture20 - COMP 250 Winter 2010 20 - binary search trees 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online