Computer Science 60
Principles of Computer Science
Spring 2008


Assignment 12: Uncomputability and algorithm efficiency...

This assignment is due on different days, depending on your section: See below for the late-day policy ~ note that you can't use a late day for problem #4!



What to submit

In the first three questions of this assignment there is no programming - for those you should write up your answers (proofs or analyses) in a plain-text or Microsoft Word file and submit it as hw12.txt or hw12.doc. For the fourth problem, you should submit your Java program in a file named Wally.java.



Late days for this assignment - important note...

You may use your remaining late days on this assignment, except for problem #4, the java problem. Since we will talk about that program on Wednesday, 4/30 and Thursday, 5/1 in class, there are no late days available for that one.



The problems

  1. (Un)computing at Nanosoft (40 Points)

    You have been hired by Nanosoft. Your boss, Gill Bates, drops by your spacious cubicle sipping a refreshing and stimulating Jolt Cola ("All the sugar, and twice the caffeine!"). Gill begins by reminding you that a decider is a program that takes an input and eventually halts and accepts (says "yes" to its inputs) or rejects (says "no" to its input). For example, a decider for the prime numbers would take a number, perhaps encoded in binary, as input and would eventually halt saying "yes" (it's prime) or "no" (it's not prime).


    Note: the idea in both of these problems is similar to the examples we did in which we reached a contradiction by creating a halt-checker out of the program that we hope to prove uncomputable. In this case, you'll want to create a halt-checker from a POTDT and a RC. Keep in mind that you can build any function/program/machine you like in order to coax the POTDT and RC into deciding whether a program P halts on an input w.

    For this reason, simply citing Rice's theorem isn't allowed for this problem :-)



    Algorithm analysis



    Through this part of the assignment, you will be analyzing the running time of algorithms. We will be interested in worst-case analysis. (The best case isn't interesting and the average case is often quite difficult to quantify.) You will need to express the worst-case running time using big-O notation. Finally, make sure to show all of your work in each written problem. Explain each step carefully.

  2. Warmup! [20 Points]

    This problem involves finding the big-O running-time analysis of both iterative (looping) and recursive code.



  3. Fast Multiplication! [40 Points]

    In this problem we consider the problem of multiplying two n-bit numbers, x and y. For simplicity, we will assume that n is a power of 2. This is generally the case in any real-world computer architecture, but it's also true that relaxing this assumption does not change the results of the analysis.

  4. Wally Wends Westward... [50 Points]

    This problem provides a chance to exercise your own algorithm-design skills, to estimate the big-O complexity of your algorithm, and then to try out your code to see how quickly it runs in practice on problems of increasing size.

    The problem

    Wally is unicycling back to Mudd (@ the southwest corner of the map) after spending the summer in New England (@ the northeast corner). A square grid has been overlaid on the map, with each cell containing a positive number -- namely, the number of strawberry-filled DonutMan donuts that Wally will need to consume in order to have enough energy to pass through that cell.

    Your task is to minimize donut consumption. And for this problem specifically, you should write

    The rest is up to you... the algorithm, the software structure (other classes, other methods), and the testing you do.

    Example

    For example, here is an image of a 5x5 donut-consumption grid and the correct minimum answer. Note that the start cell will be in the final spot in the first row, or map[0][N-1], and that the destination cell is in the final spot of the first column, or map[N-1][0], where N is the length of a side of the square map.

    Below it is the path that produced that answer:


    The write-up

    You should comment your code in order to explain how your algorithm works, as usual. However, you should also include a comment at the top of your file that includes


    You may cite any results from class to justify your claim to a particular big-O running time, but you may also need to supplement those results with additional analysis of your own.

    For uniformity, we ask that everyone define the problem size, N, to be the length of ONE SIDE of the square donut-consumption grid.

    Submission

    Submit Wally.java in the usual way, under assignment #12.

    Scoring

    Your solution will receive full correctness credit if it runs in "reasonable" time (under ten seconds on a 6x6 grid) and it works correctly, i.e., it computes the true minimum donut cost. Slow correct solutions will receive almost all of the points (unless they are bogosort-slow). Incorrect solutions, fast or slow, will receive almost no points.

    The other half of the credit will be for your algorithm deisgn (not speed, just thoughtfulness), explanation, program design, and commenting.



    Extra Credit Options