CSSE 230: Exercise on Skiplists

The purpose of this exercise is to understand in detail the mechanics of insertion and removal of elements from skiplists.
  1. Work on this exercise by yourself.
  2. This is an extra credit assignment.
  3. Create a new project called SkipList. Have an inner class called Node
  4. Use parameterized generics.
  5. Implement public boolean insert(T e) and public boolean remove(T e) methods.
  6. The head node is to have a size of 21. This is the maximum size of any node in the skiplist.
  7. For testing purposes, implement a public boolean insert(T e, int size) method which creates a node with element "e" and an ArrayList of pointers to the next node that is of size "size". Notice that the regular method uses a random generator to determine the size of a node.
  8. Calling insert as follows, results in the SkipList shown below:
    insert(4, 3)
    insert(5, 1)
    insert(7, 3)
    insert(6, 4)
    
    [r [0: 4][1: 4][2: 4][3: 6][4: null][5: null][6: null][7: null][8: null][9: null]] ...
    [4 [0: 5][1: 6][2: 6]]
    [5 [0: 6]]
    [6 [0: 7][1: 7][2: 7][3: null]]
    [7 [0: null][1: null][2: null]]
    
  9. Node class: For testing purposes, have a method getLinks() which returns an arraylist. Calling this method on a node returns the links of the node.
  10. Node class: For testing purposes, have a method getElement() which returns the element at that node.
  11. Skiplist class: For testing purposes, make the root element of the Skiplist class public.
  12. Use the following unit test cases as well as additional test cases of your own choosing to develop and debug your software. In particular, it may be helpful to have a toString() method which enables you to visualize the nodes and their links.
  13. Please submit your SkipList.java file to the appropriate drop-box on Moodle.