Lesson 1.3: Algorithms Flashcards
Is defined as the finite sequence of instructions, each of which has a clear meaning and can be performed with a finite amount of effort in a finite length of time.
Algorithm
IT is a set of steps, to accomplish a task.
Algorithm
Optimization of a program is directly concerned with __________?
Algorithm Design
Incremental approach to the construction of program structure. Modules are integrated by moving downward through the control hierarchy. Starting module is the main program.
Top-down design
Works in opposite direction. Starting with specific modules and build them into more complex structures, ending at the top.
Bottom-up design
This algorithm complexity deals with the amount of time it needs to run to completion
Time Complexity
This algorithm complexity deals with the amount of space it needs to run to completion
Space Complexity
Choosing an approach depending on the constraints.
Time-Space Trade-Off
Is a characterization scheme that allows us to measure the properties of algorithms.
Big Oh
The 7 algorithms. (CLLQPEF)
- Constant time algorithm
- Logarithmic time algorithm
- Linear time algorithm
- Quasilinear time algorithm
- Polynomial time algorithm
- Exponential time algorithm
- Factorial time algorithm
Algorithms under this class take a constant amount of time no matter how big is the problem. For example, taking the average of three numbers.
Constant time algorithm O(1)
These algorithms typically divide the number of items it must consider by a fixed fraction every step. Usually, the base of the algorithm is 2 because inputs are being divided into two groups repeatedly.
Logarithmic time algorithm O(lg n)
These algorithms go through all of the elements or inputs that they need to process. An example is finding the maximum (or minimum) of an array).
Linear time algorithm O(n)
These algorithms loop over all the items and for each loop performs O(lg n) calculations on that item. Examples are some efficient sorting algorithms we will cover in Module 4 like quicksort, mergesort, etc.
Quasilinear time algorithm O(n lg n)
These algorithms loop over the input, and for every input, loop over the inputs again (for the case of O(n2)). This is considered a polynomial runtime if runtime involves any polynomial involving n. A good example is of a polynomial algorithm O(n2) is bubble sort.
Polynomial time algorithm O(n^2), O(n^3), …, O(n^100), etc.