Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java implement the Map ADT based on Skip List, which is in Section 10.4. That means implementing all the 8 functions based on Skip
In Java implement the Map ADT based on Skip List, which is in Section 10.4. That means implementing all the 8 functions based on Skip List and run your codes on Example 10.1. Your program should print out that table in Example 10.1
Functions:
nce a map stores a collection of objects, it should be viewed as a collection of y-value pairs. As an ADT, a map M supports the following methods: size( ): Returns the number of entries in M. isEmpty( ): Returns a boolean indicating whether M is empty. get (k) : Returns the value v associated with key k, if such an entry exists; otherwise returns null. put(k,v) : If M does not have an entry with key equal to k, then adds entry (k,v) to M and returns null; else, replaces with v the existing value of the entry with key equal to k and returns the old value. remove( (k) : Removes from M the entry with key equal to k, and returns its value; if M has no such entry, then returns null. keySet( ): Returns an iterable collection containing all the keys stored in M. values( ): Returns an iterable collection containing all the values of entries stored in M (with repetition if multiple keys map to the same value). entrySet ( ): Returns an iterable collection containing all the key-value entries in M. \begin{tabular}{|c|c|c|} \hline \hline Method & Return Value & Map \\ \hline isEmpty() & true & \{\} \\ put (5,A) & null & {(5,A)} \\ put (7,B) & null & {(5,A),(7,B)} \\ put (2,C) & null & {(5,A),(7,B),(2,C)} \\ put (8,D) & null & {(5,A),(7,B),(2,C),(8,D)} \\ put (2,E) & C & {(5,A),(7,B),(2,E),(8,D)} \\ get (7) & B & {(5,A),(7,B),(2,E),(8,D)} \\ get(4) & null & {(5,A),(7,B),(2,E),(8,D)} \\ get(2) & E & {(5,A),(7,B),(2,E),(8,D)} \\ size() & 4 & {(5,A),(7,B),(2,E),(8,D)} \\ remove (5) & A & {(7,B),(2,E),(8,D)} \\ remove(2) & E & {(7,B),(8,D)} \\ get(2) & null & {(7,B),(8,D)} \\ remove (2) & null & {(7,B),(8,D)} \\ isEmpty () & false & {(7,B),(8,D)} \\ entrySet () & {(7,B),(8,D)} & {(7,B),(8,D)} \\ keySet() & {7,8} & {(7,B),(8,D)} \\ values() & {B,D} & {(7,B),(8,D)} \\ \hline \hline \end{tabular}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started