

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CMPSC 130A: Spring 2009
Programming Assignment 2
Assigned: May 14, 2009 Due: May 28, 2009 (Thur midnight)
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.
User Operations
The splay trees support the following user operations:
Implementation
Internally, you will implement these operations as follows.
How your program will be graded.
First, make sure that the main of your program clearly has your name at the top. Second, include a clearly written README file telling the TA how to compile and/or run your program. Finally, you must do the following:
(a) access i: your program shall determine if i is in the tree, and report the depth of the last node searched. (b) insert i: your program shall insert i. (c) delete i: your program shall delete i from the tree.
In case of error, output -1. For successful insertion/deletion, output 0.