Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help in this java code. ------------------------------------------------------------------------------------------------------------------------------------------------- // Starter code skip lists package rbk; import java.util.Iterator; public class SkipList > { static final int PossibleLevels

Please help in this java code.

image text in transcribed

-------------------------------------------------------------------------------------------------------------------------------------------------

// Starter code skip lists package rbk; import java.util.Iterator; public class SkipList> { static final int PossibleLevels = 33; static class Entry { E element; Entry[] next; Entry prev; public Entry(E x, int lev) { element = x; next = new Entry[lev]; // add more code as needed } public E getElement() { return element; } } // Constructor public SkipList() { } // Add x to list. If x already exists, reject it. Returns true if new node is added to list public boolean add(T x) { return true; } // Find smallest element that is greater or equal to x public T ceiling(T x) { return null; } // Does list contain x? public boolean contains(T x) { return false; } // Return first element of list public T first() { return null; } // Find largest element that is less than or equal to x public T floor(T x) { return null; } // Return element at index n of list. First element is at index 0. public T get(int n) { return null; } // Is the list empty? public boolean isEmpty() { return false; } // Iterate through the elements of list in sorted order public Iterator iterator() { return null; } // Return last element of list public T last() { return null; } // Remove x from list. Removed element is returned. Return null if x not in list public T remove(T x) { return null; } // Return the number of elements in the list public int size() { return 0; } }
Implement the following operations of skip lists, following the algorithms discussed in class. starter code is provided. A driver program is also provided Sample inputs and outputs will be provided Do not change the signatures of methods declared to be public. You can add additional fields, nested classes, and methods as needed. Do not create additional source files. Place all code in skipList.java * add(x): Add a new element x to the list. If x already exists in the skip list, replace it and return false. otherwise, insert x into the skip list and return true. * ceiling(x): Find smallest element that is greater or equal to x. contains (x): Does list contain x? first): Return first element of list. * floor(x): Find largest element that is less than or equal to x. *get(n): Return element at index n of list. First element is at index * isEmpty(): Is the list empty? *iterator(): Iterator for going through the elements of list in sorted order * last(): Return last element of list. remove(x): Remove x from the list. If successful, removed element is returned. otherwise, return null. * size(): Return the number of elements in the list. Implement the following operations of skip lists, following the algorithms discussed in class. starter code is provided. A driver program is also provided Sample inputs and outputs will be provided Do not change the signatures of methods declared to be public. You can add additional fields, nested classes, and methods as needed. Do not create additional source files. Place all code in skipList.java * add(x): Add a new element x to the list. If x already exists in the skip list, replace it and return false. otherwise, insert x into the skip list and return true. * ceiling(x): Find smallest element that is greater or equal to x. contains (x): Does list contain x? first): Return first element of list. * floor(x): Find largest element that is less than or equal to x. *get(n): Return element at index n of list. First element is at index * isEmpty(): Is the list empty? *iterator(): Iterator for going through the elements of list in sorted order * last(): Return last element of list. remove(x): Remove x from the list. If successful, removed element is returned. otherwise, return null. * size(): Return the number of elements in the list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

Does diversity make good business sense? Explain your answer.

Answered: 1 week ago

Question

Evaluate how concurrent engineering deals with misalignment.

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago