| Homework 13General Comments
- For full credit, provide context for each problem, show all calculations,
and justify all answers by providing enough comments to explain your reasoning.
- Homework assignments must be very neatly written or typeset
(e.g. using Word or OpenOffice).
- You can get up to 50% credit on a problem if you get significant outside assistance. Thus, if you are totally stuck on a problem it might be worth getting help. However, you must indicate any assistance/collaboration (See the Homework Assistance section on the Policies page). Failure to do so could result in a failing grade for the course! Note that getting help from the Help Center or me does not count as significant outside assistance, but talking with your classmates or searching on the Internet does!
- If a problem asks for an algorithm,
you should give the most efficient algorithm you can find to ensure full credit.
You should also specify the complexity of the algorithm with justification,
whether or not the problem asks for it.
Details
- (8) Design an efficient algorithm to find all anagrams of a given word using
a list of words from a dictionary (which you can assume is in alphabetical order). For instance, given tea, the algorithm would output eat, ate, tea, etc., but not aet since that is not a word in the dictionary.
Give the worst-case complexity of your algorithm given that the dictionary has m words, the input word has n characters, and for simplicity assume the average word in the dictionary has k characters.
- (25) Show all of the steps of inserting the letter of ALGORITHMS into each of the following data structures in order (e.g. A, then L, etc.)
- A regular (unbalanced) BST
- An AVL tree
- A 2-3tree
- A Min Heap
- A Max Heap
- (8) Compute
131303 mod 101
by hand using one of the binary exponentiation algorithms.
That is, you are not allowed to use a calculator, computer, abacus, or any other computational device besides your brain.
Show all of your work (which should be a table with 3-5 columns).
You are permitted to verify that your answer is correct with the use of a computer or calculator.
In case it is not clear, you may do all of your intermediate computations modulo 101 and you will still get the same answer. For instance,
13*13=169=68 mod 101, so you can use 68 instead of 169
in the next calculation.
|
|
|