// 2000 APCS Exam A: Question 3 A WordCollection, shown in the class declaration below, stores a group of words. The collection may store multiple instances of any word. In this question, you will not implement any of the member functions of the class WordCollection. class WordCollection{ public: int Size() const; // returns the total number of items stored in // the collection void Insert(const apstring & word); // adds word to the collection (duplicates allowed) void Remove(const apstring &word); // removes one instance of word from the collection // if word is present; otherwise does nothing apstring FindKth(int k) const; // returns kth word in alphabetical order, where 1<=k<=Size() // other public member functions not shown private: // private data members not shown }; The public member function FindKth returns the kth word in alphabetical order from the collection (the word with rank k), even though the underlying implementation of WordCollection may not be sorted. The rank ranges from 1 (first in alphabetical order) to N where N is the number of words in the collection. For example, assume that WordCollection C stores the following words: ("at", "bad", "all" , "at") The following table illustrates the results of calling C.FindKth(k): k C.FindKth(k) ------------------ 1 "all" 2 "at" 3 "at" 4 "bad" (a)************************************************************************** Write free function Occurrences, as stated below. Occurrences returns the number of times that word appears in WordCOllection C. If word is not in C, Occurrences should return 0. In writing Occurrences, you may call any of the member functions of the WordCollection class. Assume that the member fuctions work as specified. Complete function Occurrences using the following header: int Occurrences (const WordCollection &C, const apstring & word) // postcondition: returns the nuber of occurrences of word in C (b)************************************************************************** Write free function RemoveDuplicates, as stated below. RemoveDuplicates removes all but one occurrence of word from C, if word is not in collection C, then RemoveDuplicates does nothing. In writing RemoveDuplicates, you may call function Occurrences specified in the previous section. Complete function RemoveDuplicates using the following header: void RemoveDuplicates(WordCollection & C, const apstring & word) // postcondition: if word is present in C, all but one occurrence is removed // otherwise, C is unchanged (C)************************************************************************ Write free function MostCommon, as stated below. MostCommon returns the word that appears most often in the collection. If there is more than one such word, return any one of them. You may assume that C is not empty. In writing MostCommon, you may call function Occurrences specified earlier in this question. Assume that Occurrences works as specified, regardless of what you wrote. Complete function MostCommon using the following header: apstring MostCommon(const WordCollection & C) // precondition: C is not empty // postcondition: returns the word that appears most often in C; // if there is more than one such word, returns any one of those // words