YCP Logo Assignment 5: Skip List Implementation

Due: Tuesday, Mar 30th by 11:59 PM

Getting Started

Download CS350_Assign5.zip. Import it into your Eclipse workspace (File->Import...->General->Existing projects into workspace->Archive File). You will see a project called CS350_Assign5 in the Package Explorer.

Do not use java.util

In this course, you are required to implement all data structures from scratch. Do not use any of the classes in the java.util package.

Exceptions: You may use java.util.StringTokenizer and java.util.Random.

Do not copy code from textbook or other sources

Some assignments in this course may involve data structures which are implemented by source code in the textbook. And, of course, lots of code is available from web sites and other sources.

I expect you to implement all data structures and algorithms from scratch, using your knowledge of how they work. Do not copy code from any source, including the textbook.

Exception: You may use any code explicitly posted on the course web site. You may also adapt pseudo-code described in papers or notes linked from the web site (e.g., the skip list paper.)

Your Task

First task:

Complete the implementation of the YSkipList<K, V> class. The class is intended to be a concrete implementation of a map, using a skip list as the underlying data structure.

The class implements the YMap<K, V> interface, which is similar to the java.util.Map<K, V> interface.

See the documentation comments for details about how the various methods of the YSkipList class should be implemented.

Second task:

Add JUnit tests to the YSkipListTest class. Some very basic tests are included, but you will need to write additional tests to ensure that your skip list implementation is tested thorougly.


You will need to define a node class. Each node object will store

  • a key
  • a value associated with the key
  • an array or 1 or more forward pointers

Your YSkipList class will need to create node objects to represent the header and nil nodes.

The pseudo-code in the skip list paper assumes that array indices start at 1. You will probably want to adapt the algorithms to reflect the fact that Java arrays are indexed starting from 0.

Your YSkipList class should use an instance of java.util.Random to generate the random values needed in the selection of the level of newly-created list nodes. E.g., if you have a field called rand that points to an instance of java.util.Random, then


yields a randomly-selected integer value in the range 0..P-1.

You should write a variety of tests to ensure that your skip list works correctly. In addition to small tests (such as the ones included in the assignment skeleton), you should write some "large" tests that

  • insert a large number of keys (thousands) into the skip list
  • verify that the keys were inserted correctly
  • remove some (but not all) of the keys
  • verify that the removed keys were removed correctly, but the remaining keys are still in the skip list

It is a very good idea to use code coverage to check that your tests are comprehensive. (Right-click on the test class, then choose Coverage As->JUnit Test.)

Your iterator implementation only needs to implement the hasNext and next methods. You may implement the remove method for extra credit. Note that the iterator traverses instances of the YPair<K,V> data type. You may find it convenient to have your node class implement this interface so that the iterator can return references to node objects from its next method.


Your assignment grade will be determined as follows:

  • 70% based on correct implementation of the put, get, remove, and iterator operations
  • 30% based on comprehensiveness of tests
  • 5% extra credit for implementing the iterator remove method


Export your finished project to a zip file (right-click on the project, then Export...->Archive File). Upload the zip file to the marmoset server as project assign5. The server URL is


IMPORTANT: after uploading, you should download a copy of your submission and double-check it to make sure that it contains the correct files. You are responsible for making sure your submission is correct. You may receive a grade of 0 for an incorrectly submitted assignment.