project4 - Spring 2009 CS 32 Programming Assignment 4...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Spring 2009 CS 32 Programming Assignment 4 Anagrams Time due: 9:00 PM Thursday, June 4 An anagram of a collection of letters is a word that is a rearrangement of all the letters in that collection. For example, anagrams of "idte" are "diet", "edit", and "tide". An anagram of "importunate" is "permutation". An anagram of "excitation" is "intoxicate". Here is the interface for a class that stores words and lets you find anagrams: class Dictionary { public: Dictionary(); ~Dictionary(); void insert(const std::string& word); void callback(const std::string&)) const; }; As you would expect, the constructor creates an empty dictionary, and the insert function adds a word to the dictionary. The lookup function takes a string and a callback function, and for every word in the dictionary that is an anagram of the letters in the string, it calls the callback function with that word as an argument. (This should be clearer when you examine the code we provide.) We have written a correct but horridly inefficient Dictionary implementation . Your assignment is to write a more efficient correct implementation. If you wish, you can do this by starting with our implementation, and changing the data structures and algorithms that implement the class and its member functions. You may add, change, or delete classes or functions if you want to. Correctness will count for 40% of your score, although if you turn in a correct implementation that is no faster than the horribly inefficient one we gave you, you will get zero correctness points (since you could just as well have turned in that same horribly inefficient program). Of course, we have to give you some assumptions about the way clients will use Dictionary so that you know what needs to be faster. The client may call insert tens of thousands of times. The collection of letters for which we want to find all the anagrams is
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/24/2012 for the course CS CS 32 taught by Professor Mojavi during the Spring '08 term at UCLA.

Page1 / 3

project4 - Spring 2009 CS 32 Programming Assignment 4...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online