An algorithm is a well defined computation procedure for processing a given input to produce a desired output.

This course covers how to design algorithms and how to analyze their performance.

Course structure

  1. Introduction
    1. Example: Stable matching problem
    2. Math background
    3. Basic graph algorithms
  2. Algorithm design techniques
    1. Greedy Algorithms
    2. Divide and conquer algorithms
    3. Dynamic programming
    4. Augmenting path methods
  3. Intractability
    1. NP-completeness
    2. Approximation algorithms
  4. Other models of computations
    1. Randomized algorithms
    2. Quantum algorithms

Specifying algorithms

To specify an algorithm, you can either use pseudocode or just a plain language description. Which one you should use is based on context and what your goal is. Want to just explain things in the clearest possible way, as these specifications will be read by other people, not by a computer.


Example:

int foo = 0
for (i = 0; i <= 100; i += 2)
	if x[i] != 0
		foo++
	endif
endfor

Instead, we could be a bit more abstract and language agnostic.

let foo be a counter initialized to 0
for every even value of i from 0 to 100
	if the ith entry of foo is nonzero, increment foo

The latter method of specifying algorithms is preferred for the class. It is less ambiguous, and what you are trying to do is more clearer. But you should take care to not oversimplify.


Example:

repeatedly find adjacent elements that are out of order and swap them
 until the list is sorted

This is very unclear and unambiguous, this should be avoided. Leaves a lot of the important specification details out.