1. Implement the dictionary ADT of Figure 4.27 based on stacks. Your implementation should declare and use two stacks.
2. Implement the dictionary ADT of Figure 4.27 based on queues. Your implementation should declare and use two queues.
Description A) Implement the dictionary ADT of the following dictionary based on stacks. Your implementation should declare and use two stacks. B) Implement the previous dictionary ADT based on queues. Your implementation should declare and use two queues. The ADT for a simple dictionary: // The Dictionary abstract class. template class Dictionary { private: void operator =(const Dictionary&) {} Dictionary(const Dictionary&) {} public: Dictionary() {} // Default constructor virtual ˜Dictionary() {} // Base destructor // Reinitialize dictionary virtual void clear() = 0; // Insert a record // k: The key for the record being inserted. // e: The record being inserted. virtual void insert(const Key& k, const E& e) = 0; // Remove and return a record. // 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. virtual E remove(const Key& k) = 0; // Remove and return an arbitrary record from dictionary. // Return: The record removed, or NULL if none exists. virtual E removeAny() = 0; // Return: A record matching "k" (NULL if none exists). // If multiple records match, return an arbitrary one. // k: The key of the record to find virtual E find(const Key& k) const = 0; // Return the number of records in the dictionary. virtual int size() = 0; };
Students succeed in their courses by connecting and communicating with an expert until they receive help on their questions
Consult our trusted tutors.