Writing Style Guide

This document is a rough guide on writing up solutions for the algorithms class. It is prepared by Chris Calabro

Length

Write-ups should not be excessively long. Get to the point fast. A typical problem will require a writeup of 1-2 pages, but this is just an estimate, not a hard rule. If you can argue your point in 1 paragraph, that's even better. The hard rule is

Of course if you have some amazing insight into the problem that is not asked for, like an optimality or tightness proof, feel free to share it. You will not lose points as long as the part that is asked for is efficient.

Writing Style

The key idea of the algorithm should be conveyed clearly. Following that should come algorithmic details such as what data structures are involved. (For example, "To remove the least weighted edge in O(ln n) time, we maintain a minheap.") Pseudocode can be provided if you find it useful, but reading it should not be necessary to make your algorithmic approach clear. The idea is that an algorithm should be conveyed several times, in increasing level of detail.

Proof must always be provided at a level of detail allowing a peer to be convinced. This may involve equations, induction, combinatoric reasoning, etc., and should be written in prose. Almost any proof in the textbook serves as a good model.

State any extra assumptions that you need. For example, "The graph G is represented as an array of adjacency lists, and we assume that the adjacency lists are sorted."

In this class we will be primarily interested in 3 properties of algorithms:

Correctness

Correctness of an algorithm is often (but not always) proved in 2 parts: first we show that it yields the correct output upon termination, and then we show that it terminates. This division often makes the proof easier. For example, consider the following pseudocode.

INPUT: a satisfiable conjunctive normal form formula F in the variables x1,...,xn OUTPUT: an assignment to x=(x1,...xn) such that F(x)=1    if F(0)==1, return 0   choose prime p>=2^n   g=0   do     g++     found=1     for each prime q|p-1       if g^((p-1)/q)=1         found=0         break   until found   x = 1   while F(x mod 2^n)==0     x = g * x mod p   return x mod 2^n

It is clear that the output is correct if the algorithm terminates, but it is less clear that the algorithm terminates, so the majority of the effort in proving correctness will be in proving the latter. In this example, x runs through a strange permutation of all of the numbers in [1,p-1] and so will hit a solution if there is one.

By contrast, in the Ford-Fulkerson method for network flow, it is clear that the algorithm terminates but it is less clear that it is partially correct. Indeed, for most algorithms in this class, termination will be clear.

Complexity

The most typical measures of resource consumption for an algorithm are time and space, though sometimes we care about others, such as number of key comparisons for a sorting algorithm. We usually care about worst case resource consumption and occasionally expected resource consumption. (expected values taken over the random choices that the algorithm makes), and almost always care more about time than space. Usually, we do not assume any particular distribution of the input. We might as well assume that some adversary has access to the code of our algorithm and gives an input designed to thwart our algorithm.

Big-Oh class is usually sufficient, but occasionally we will want an exact quantity. All relevant parameters should be included in the expression. For example, Theta(m+n) time is required to add an m-bit number to an n-bit number. To see the lower bound, note that any algorithm A must examine all of the bits. To see the upper bound, use the grade school addition method (say, on a RAM model). If we know that m<=n, then we may simplify this to Theta(n).

Optimality

We will be concerned with 3 only occasionally - such results are hard to come by.

Giving credit

Give credit to any other students who contributed key ideas. Credit should be given when using ideas from research papers, especially when obscure. For example, "by a slight modification to the Agrawal-Kayal-Saxena algorithm..." You do not need to give credit to the professor, the TA, nor the textbook (though possibly to the author of an algorithm appearing in the textbook!). Innocent citation mistakes will not be brutally penalized.

Minor Infractions

The following is a non-exhaustive list of mistakes that may cause the loss of 0 to 1 points.

Major Infractions

These may cause greater loss of credit.

How to write a good proof

The following suggestions need not be followed rigorously, but may help you to improve clarity. Notice how good proof writing practice mirrors good programming practice.

Last modified 10/20/23