prog2 - CMPSC 130A Winter 2011 Programming Assignment 2...

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 Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMPSC 130A: Winter 2011 Programming Assignment 2 Assigned: Feb 17, 2011 Due: Mar 1, 2011 (11:59 PM) Your second programming assignment is to implement the splay trees . Recall that splay trees are balanced search trees in which no explicit balance condition is maintained; instead, a simple restructuring heuristic is used after each access. Splaying Specifically, whenever a node x is accessed (either by search, or insert, or delete), the following splay operation is repeated at x until it becomes the root. In the following, p ( x ) denotes the parent of node x . • Case 1 : if p ( x ) is the root, rotate the edge between x and p ( x ); and terminate. • Case 2 : [Two Single Rotations] if p ( x ) is not the root and x and p ( x ) are both left or both right children, first rotate the edge joining p ( x ) with x ’s grandparent g ( x ), and then rotate the edge joining x with p ( x ). • Case 3 : [Double Rotation] if p ( x ) is not the root and x is a left child and p ( x ) is a right child, or vice versa, then rotate the edge joining x with p ( x ) and then rotate the edge joining x with its new parent....
View Full Document

{[ snackBarMessage ]}

Page1 / 2

prog2 - CMPSC 130A Winter 2011 Programming Assignment 2...

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