Jumble
Word X is a jumble of word Y if the letters in X can be rearranged
to give Y. For example: backwards drawbacks.
Given a dictionary as input, find the largest group of words
all of which are jumbles of eachother.
Steps
- Understand the problem
- Understand the question
- Solution involves a program
- Write an algorithm.
- Convince yourself that the algorithm is reasonable
- Convert this to code
- Learn about the language/subroutines along the way
- Go from firm ground to firm ground (ie if not familiar
with syntax, then compile often). Write small pieces
and check that they work.
- Make sure that your code corresponds to your algorithm
- Do I really understand the problem? If so the solution
is simple, clear and obvious.
- If the solution seems more complex than my understanding
then simplify it.
Solutions
- words (the dictionary)
- Jumble.java
is an implementation of algorithm we developed in class.
You should check it to see if you think it works.
It is not as clean and
simple as possible, that involves better understanding and more work.
Try running it on the list of words I have supplied.
I placed a counter in the code so you can see it running.
There seems to be a problem!! Can you identify it?
Hint: You should be able to write down a simple mathematical expression
to convince me that you know and understand the problem.
- Jumble.java A java solution using a TreeMap (and the
alternate approach). Should this approach work better than the one above?
- Complexity.java demonstrates the difference between
the time complexity of the two versions of Jumble.java above.
- jumble2.pl A version in perl which uses hashing.