[TOC]
An algorithm is a finite sequence of precise instructions for performing a computation or for solving a problem.
The properties of the algorithm are:
Input. An algorithm has input values from a specified set.Output. From each set of input values, an algorithm produces output values from a specified set. The output values are the solution to the problem.Definiteness. The steps of an algorithm must be defined precisely.Correctness. An algorithm should produce the correct output values for each set of input values.Finiteness. An algorithm should produce the desired output after a finite (but perhaps large) number of steps for any input in the set.Effectiveness. It must be possible to perform each step of an algorithm exactly and in a finite amount of time.Generality. The procedure should be applicable for all problems of the desired form, not just for a particular set of input values.
THE LINEAR SEARCH. The linear search algorithm begins by comparing
THE BINARY SEARCH. The binary search algorithm proceeds by comparing the element to be located to the middle term of the list. The list is then split into two smaller sublists of the same size, or where one of these smaller lists has one fewer term than the other. The search continues by restricting the search to the appropriate sublist based on the comparison of the element to be located and the middle term.
THE BUBBLE SORT. The bubble sort puts a list into increasing order by successively comparing adjacent elements, interchanging them if they are in the wrong order.
THE INSERTION SORT. In the $j$th step of the insertion sort, the $j$th element of the list is inserted into the correct position in the list of the previously sorted
Algorithms that make what seems to be the "best" choice at each step are called greedy algorithms.
THEOREM: The cashier's algorithm always makes changes using the fewest coins possible when change is made from quarters, dimes, nickels, and pennies.
LEMMA: If
Halting problem. It asks whether there is a procedure that does this: It takes as input a computer program and input to the program, and determines whether the program will eventually stop when run with this input.
Definition: Let
THEOREM: Let
HEOREM**: Suppose that
COROLLARY: Suppose that
THEOREM Suppose that
Definition Let
Definition Let order same order.
THEOREM Let
An analysis of the time required to solve a problem of a particular size involves the time complexity of the algorithm.
An analysis of the computer memory required involves the space complexity of the algorithm.
WORST-CASE COMPLEXITY By the worst-case performance of an algorithm, we mean the largest number of operations needed to solve the given problem using this algorithm on an input of specified size.
AVERAGE-CASE COMPLEXITY The average number of operations used to solve the problem over all possible inputs of a given size is found in this type of analysis.
Commonly Used Terminology for the Complexity of Algorithms:
| Complexity | Terminology |
|---|---|
| Constant complexity | |
| Logarithmic complexity | |
| Linear complexity | |
| Linearithmic complexity | |
| Polynomial complexity | |
| Exponential complexity | |
| Factorial complexity |
TRACTABILITY A problem that is solvable using an algorithm with polynomial (or better) worst-cast complexity is called tractable, because the expectation is that the algorithm will produce the solution to the problem for reasonably sized input in a relatively short time.
[1] Kenneth H. Rosen. Discrete Mathematics and Its Applications. 8Edition
