Question: Implement the dictionary ADT of Figure 4.27 based on stacks. Your implementation should declare and use two stacks. /** The Dictionary abstract class. */ public
Implement the dictionary ADT of Figure 4.27 based on stacks. Your implementation should declare and use two stacks.

/** The Dictionary abstract class. */ public interface Dictionary { }; /** Reinitialize dictionary */ public void clear(); /** Insert a record @param k The key for the record being inserted. @param e The record being inserted. */ public void insert (K k, E e); /** Remove and return a record. @param k The key of the record to be removed. @return A maching record. If multiple records match "k", remove an arbitrary one. Return null if no record with key "k" exists. */ public E remove (K k); /** Remove and return an arbitrary record from dictionary. @return the record removed, or null if none exists. */ public E removeAny (); /** @return A record matching "k" (null if none exists). If multiple records match, return an arbitrary one. */ public E find (K k); /** @return the number of records in the dictionary. */ public int size (); Figure 4.27 The abstract class definition for a simple dictionary.
Step by Step Solution
There are 3 Steps involved in it
Java import javautilStack public class StackDictionary implements Dictionary private Stack keyStack ... View full answer
Get step-by-step solutions from verified subject matter experts
