2. The Mathematics of Algorithms Flashcards
How does the size and encoding of a problem instance affect algorithmic performance?
In most problems, the execution time of a program increases with the size of the data set. At the same time, overly compact representations may unnecessarily slow down the execution of the program. The encoding of the problem instance should not be the determining factor in whether the algorithm can be implemented efficiently. Proper data structures should be selected to represent the problem in order to design an efficient algorithm.
How do constants affect algorithmic performance?
Some constants are assumed, such as standard integers being represented as four-byte words in computer architecture, but generally only affect algorithmic performance as a multiplicative constant. Algorithm designers generally ignore constants because performance costs that differ by a multiplicative constant are asymptotically equivalent. However, they may be important to take into consideration when implementing an algorithm in production code.
How is algorithmic efficiency classified?
Algorithmic efficiency is classified according to the rate of growth of its execution time as a function of the size of the input problem instance. This common abstraction, however, ignores numerous details of the computing platform, such as the CPU, programming language and compiler, operating system, and other processes that may be running.
Mathematically, what is the average performance of Sequential Search?
Where n is the number of distinct elements in the list and E(n) is the average number of examined elements:
E(n) = 1/n*(sum of all i in n) = (n*(n+1))/2n = ½n + ½
Why is Sequential Search considered to have a linear rate of growth?
Because the number of elements examined scales linearly with increases in the size of the problem instance. The average number of probes is c*n, where c = 0.5. A fundamental fact of performance analysis is that the constant c is unimportant in the long run, because the most important cost factor is the size of the problem instance, n. Hence, the constant multiplier is ignored during algorithmic analysis.
Why should the rate of growth not be the only consideration when selecting an algorithm?
Because constants matter (evidenced by the use of more powerful computers) and the size of n is not always large.
How can the performance of an algorithm be predicted?
Through a statistical process known as regression analysis. The “fitness” of a trend line to the actual data is based on a value between 0 and 1, known as the R2 value. R2 values near 1 indicate high fitness.
What is an example of an algorithm that demonstrates multiple distinct behavioral patterns?
For example, the Quicksort algorithm by Bentley and McIlroy is optimized by varying the strategy for problem sizes 7 and less, between 8 and 39, and for 40 and higher.
What are some examples of different problem instances that might affect sorting algorithm performance?
- The data could contain large runs of elements already in sorted order.
- The input could contain duplicate values.
- Regardless of the size of n, the elements could be drawn from a much smaller set and contain a large number of duplicate values.
Why may no single optimal algorithm exist for a given problem?
The worst case, average case, and best case may differ for different problem instances.
Why is it valuable to know the worst-case performance of an algorithm?
It explains the maximum execution time that could occur in practice. It is also often the easiest case to analyze.
How is the average-case performance computed for an algorithm?
The probability of a problem instance occurring is multiplied by its runtime, and the average-case is taken to be the sum of all these weighted probabilities for the entire set of the problem instances.
Why is it valuable to know the best-case performance for an algorithm?
Though it rarely occurs in practice, it can provide insight into the optimal circumstances for the algorithm.
What are lower and upper bounds?
The lower bound for the execution time of an algorithm is classified as Ω(f(n)) and corresponds to the best-case scenario. The upper bound for the execution time is classified as O(f(n)) and corresponds to the worst-case scenario.
What is a tight bound?
In complexity theory, another notation Θ(f(n)) combines the lower and upper bounds to identify an accurate “tight bound”, where the lower and upper bounds have the same time complexity. However, O(f(n)) is more widely, though informally, used.