Welcome To Introduction to Algorithms

Algorithm - “a well defined computational procedure that takes … input and produces … output.”

Analysis Issues

  1. What Data Structures to Use! (lists, queues, stacks, heaps, trees, etc.)
  2. Is It Correct! (all or only most of the time?)
  3. How Efficient is It! (asymptotically fixed or does it depend on the inputs?)
  4. Is There an Efficient Algorithm! - P ≟ NP

Many practical problems can be cast as mathematical ones, i.e. graphs, linear programming, string matching, etc.

Algorithmic analysis is primarily about proving that a procedure is correct and then counting the number of operations required for the procedure to execute, i.e. finding the run-time. In this class we will use mathematical “proofs” to find asymptotic bounds ignoring numerous factors that get lumped into “hidden constants”, but in real situations other overhead would ultimately want to be considered such as:

  • runtime overhead - such as memory management, function calls, etc.
  • additional auxiliary storage requirements
  • hardware functionality - such as parallel architectures

Pseudocode Conventions

We will be using pseudocode for our algorithm implementations:

  • Indentation will indicate block structures (similar to Python)
  • Loops (for, while) and decisions (if/else) follow standard C++/Java conventions, i.e. the loop counter retains its value that caused the loop to terminate (useful when proving the correctness of an algorithm)
  • // indicates comments
  • = indicates assignment (and can be used for multiple assignment)
  • Variables are local to the procedure in which they are used
  • Array elements are accessed with bracketed indices as in C++/Java, e.g. A[i]
  • The notation “..” is used to indicate a (inclusive) subarray, e.g. A[i..j] indicates the elements <A[i],A[i+1], …, A[j]>
  • Object attributes and methods are accessed using the standard “.” notation, e.g. A.length
  • Object names are treated as pointers, thus B = A creates an alias NOT a copy
  • Variables are passed by value, except for objects and arrays which are passed by reference.
  • Multiple values may be returned in a return statement
  • Boolean expressions are short circuiting, i.e. are evaluated left to right only until the value of the expression is known

Licenses and Attributions


Speak Your Mind

-->