| Homework 14General Comments
- Most problems are found in one of the following:
- Algorithms: Algorithms, Dasgupta, Papadimitriou, Vazirani
- AIDMA: An Active Introduction to Discrete Mathematics and Algorithms
- For full credit, provide context for each problem, show all calculations,
and justify all answers by providing enough comments to explain your reasoning.
- You will lose a significant amount of credit if you do not provide context,
calculations, and justifications for a problem.
- Numbers and/or algebra by themselves are not enough.
A correct answer with no justification will be worth no more than half credit,
and sometimes much less than that.
- Precision is very important. You cannot skip steps, make guesses,
or use flawed logic. Any of these things can lead to incorrect answers.
- Homework assignments must be very neatly written or typeset
(e.g. using Word or OpenOffice).
- Remember that 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
-
Algorithms 2.1 (10 points). You should use the algorithm with Gauss's trick and you should do recursive calls until n<=3 at which point you can compute those products in the normal way.
Show all of your work!
-
Algorithms 2.4 (10 points). Give and solve recurrence relations for each algorithm. You may use the Master Method/Theorem. You may also assume that each algorithm takes constant time for inputs of size 1.
-
Algorithms 2.14 (10 points). Give a clear and complete description of your algorithm.
For this algorithm, you should probably give a description of the steps rather than trying to write Java or pseudocode.
You may use algorithms we have already seen in this course or previous
courses without giving the details (e.g. you can say "Use binary search to find the value k" without giving the algorithm. Although you probably shouldn't say exactly that because binary search won't help on this problem.)
Make sure you justify that it's complexity is O(n log n).
(10 points)
Implement the modulus binary exponentiation algorithm.
You may not use any of the Java libraries (e.g. Math.pow)
and there is no need for any data structures (e.g. array, ArrayList, HashMap, etc.). The best implementation should only require a few extra
variables. You can use all of the standard operations, including the mod operator (%).
Here are the relevant files:
Submit just ModPower.java using WebHandin 255-HW14.
You should receive an e-mail with your test results.
You must write your own code for this! Do not find a solution online.
Please please do this on your own. I will penalize you heavily if you obtain your code from elsewhere and you do not specify so.
(Recall that if you get really stuck you can get help online, but for up to half credit and you MUST specify that you did so, including the source.
And you must make it clear that you understand the solution.)
|
|
|