###### Books / Analysis of Algorithms / Chapter 1

# Welcome To Introduction to Algorithms

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

## Analysis Issues

What Data Structures to Use!(lists, queues, stacks, heaps, trees, etc.)Is It Correct!(all or only most of the time?)How Efficient is It!(asymptotically fixed or does it depend on the inputs?)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:

Indentationwill indicate block structures (similar to Python)Loops(for,while) anddecisions(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)//indicatescomments=indicatesassignment(and can be used for multiple assignment)- Variables are
localto the procedure in which they are used- Array elements are accessed with
bracketed indicesas 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
attributesandmethodsare accessed using the standard “.” notation, e.g. A.length- Object names are treated as
pointers, thus B = A creates analiasNOTa copy- Variables are passed
by value, except for objects and arrays which are passedby reference.Multiple valuesmay be returned in areturnstatement- Boolean expressions are
short circuiting, i.e. are evaluated left to right only until the value of the expression is known