14-Section-Handout

14-Section-Handout - CS107 Spring 2007 Handout 14 April 18,...

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

View Full Document Right Arrow Icon
sortedset CS107 Handout 14 Spring 2007 April 18, 2007 Section Handout Handout written by Jerry. The Generic Sorted Set Binary search trees (BST) save the day whenever both search and insertion are high- priority operations. BST structures have the advantage over both sorted arrays and sorted linked lists in that insertion takes logarithmic time on the average, whereas insertion into sorted lists and arrays generally takes linear time. For this problem, we are going to implement a fully generic sortedset container using a packed binary search tree as the underlying representation. A more traditional binary search tree storing 7 client elements might look as follows: Each node of the tree consists of the binary representation of a client element immediately followed by two addresses, one for the left subtree, and one for the right subtree. Satisfying the binary search tree property mandates that: be a strictly increasing sequence according to whatever function the client uses to compare elements of this type.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2010 for the course CS 107 taught by Professor Cain,g during the Spring '08 term at Stanford.

Page1 / 3

14-Section-Handout - CS107 Spring 2007 Handout 14 April 18,...

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

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