Professional Documents
Culture Documents
Your answers to the problem set should ALL be written in the file ps1_sol.tex.
To fill in the answer to a particular problem, e.g. Problem 3(a), you should
look through the document for a pair of lines that look like this:
You should then edit the line between the START and END lines to indicate what
your answer is. Do NOT edit the marker lines. Your homework will be
automatically graded, and any changes to the marker lines or to the
surrounding document may cause you to lose points. In addition, your solutions
should follow several strict formatting requirements:
Ordering Problem
Multiple Choice
Your answer should take the form of a single number. The number should be
the number assigned to the answer you wish to choose. For instance, if
you are trying to answer a question with the answers 1. A and 2. B,
you would write the number 2 to indicate that your answer is B.
Proof
Your answer should take the form of a series of lines. These lines will
be formatted using LaTeX, but you don't need to learn all of LaTeX to
write up your proof --- all you need to learn is the basics of the math
mode. See the website for resources on this topic. The source of the
proof given in the homework should give you an idea of what we're looking
for.
Counterexamples
Collaborators
Once your solutions have been formatted in this way, upload the file
ps1_sol.tex to the Stellar website, for Problem Set 1.
********************************************************************************
******************************* CODING INSTRUCTIONS ****************************
********************************************************************************
The steps that you should take to solve this problem set are as follows:
1) First, read through the problem set in ps1.pdf. Solve the asymptotic
ordering problems and the recurrence relation problems, and place the answers
in the file ps1_sol.tex according to the instructions given above.
3) Try to understand how each of the four algorithms works. To improve your
understanding of the algorithms, we have provided a visualizer in the file
visualizer.html. To run the visualizer on a particular matrix, enter the
matrix into the file problem.py, then run the Python script main.py, and
then open the file visualizer.html in a browser. (Chrome and Chromium are the
only browsers guaranteed to work with the visualizer, but other modern browsers
are also likely to work.)
4) Analyze the runtime of each of the four algorithms. You may find it useful
to look at the comments of some of the functions in peak.py and trace.py, in
which the runtimes are given.
5) Try to figure out which algorithms are correct. You can try to do this by
running the algorithms on random matrices (generated using the Python script
generate.py), but keep in mind that random matrices have a large number of
peaks, and do not usually have a very interesting peak structure. You may
have better luck examining the algorithms in detail, and constructing
counterexamples by hand.
8) Figure out which of the correct algorithms is most efficient, and write a
proof of correctness for it.
9) Place ALL of your answers in the file ps1_sol.tex, and submit the problem
set through the Stellar website.
********************************************************************************
******************************** DIRECTORY CONTENTS ****************************
********************************************************************************
ps1.pdf
ps1_sol.tex
The file that you should fill in with your responses. Your answers should
be entered ONLY in the locations indicated, and you should NEVER change
anything outside of those locations. Your answers WILL be automatically
graded --- if you do not put them in the correct locations, you may not
get proper credit for them!
ps1_critique.tex
This is the file where you will fill in your critique of your own proof,
AFTER the assignment is due and the solutions have been released. You
should then copy and paste your proof into the designated location, and
then provide a critique of your own proof afterwards. The critique will
be due AFTER the rest of the assignment is due.
algorithms.py
generate.py
main.py
When this Python file is run, it loads a peak problem from a file that
the user specifies, and does the following:
(1) Tests all four algorithms on the desired peak problem, and
outputs the results.
When run with no arguments (such as when run in IDLE), main.py prompts
the user for a file name to read the matrix from, defaulting to problem.py.
It also takes a single optional argument (the filename to read the matrix
from):
peak.py
This file contains the code for constructing a PeakProblem object, and a
number of methods that can be called on such a problem. These methods are
used by the algorithms in algorithms.py. Each of these functions has been
labeled with its worst-case runtime, to simplify your analysis of the
four algorithms.
problem.py
Thie file contains a template for entering in a matrix. This is also the
default name for files read by main.py and written by generate.py. The
counterexamples that you submit should look like this, but instead of the
matrix we have given you, you should find a matrix that causes at least one
of the four algorithms to fail.
trace.py
This file contains the code for recording information about the sequence of
steps performed by an algorithm. Just like peak.py, it has been annotated
with runtimes to make it easier to analyze the four algorithms.
utils.py
This file contains some methods used for getting file names from the user.
None of the functions in this file are used by any of the algorithms, so
you are not responsible for reading and understanding this code.
trace.jsonp
visualizer.html
********************************************************************************
****************************** COMPATIBILITY ***********************************
********************************************************************************
This code has been verified to work with Python 2.7. It will not work with
Python 3.x.