Complexity and sorting Flashcards
What would you call a finite sequence of precise instructions for performing a computation or for solving a problem?
An algorithm
What are the seven properties of an algorithm?
Input, output, definiteness, correctness, finiteness, effectiveness and generality.
There are several properties that algorithms generally share. What does input mean in this context?
An algorithm has input values from a specified set.
There are several properties that algorithms generally share. What does output mean in this context?
From each set of input values an algorithm produces output values from a specified set.
The output values are the solution to the problem.
There are several properties that algorithms generally share. What does definiteness mean in this context?
The steps of an algorithm must be defined precisely.
There are several properties that algorithms generally share. What does correctness mean in this context?
An algorithm should produce the correct output values for each set of input values.
There are several properties that algorithms generally share. What does finiteness mean in this context?
An algorithm should produce the desired output after a finite (but perhaps large) number of steps for any input in the set.
There are several properties that algorithms generally share. What does effectiveness mean in this context?
It must be possible to perform each step of an algorithm exactly and in a finite amount of time.
There are several properties that algorithms generally share. What does generality mean in this context?
The procedure should be applicable for all problems of the desired form, not just for a particular set of input values.
What is a greedy algorithm?
This approach selects the best choice at each step, instead of considering all sequences of steps that may lead to an optimal solution. Algorithms that make what seems to be the “best” choice at each step are called greedy algorithms.
Why do you need to verify the results of a greedy algorithm?
Once we know that a greedy algorithm finds a feasible solution, we need to determine whether it has found an optimal solution. (Note that we call the algorithm “greedy” whether or not it finds an optimal solution.) To do this, we either prove that the solution is optimal or we show that there is a counterexample where the algorithm yields a nonoptimal solution.
Name different types of algorithms.
When we talk about different types of algorithmic paradigms, we refer also to: greedy algorithm, brute-force algorithms, divide-and-conquer algorithms, probabilistic algorithms, backtracking and dynamic programming.
What are brute-force algorithms designed for?
Brute-force algorithms are designed to solve problems without regard to the computing resources required. For example, in some brute-force algorithms the solution to a problem is found by examining every possible solution, looking for the best possible.
What is a randomised algorithm?
A randomized algorithm is an algorithm which employs a degree of randomness as part of its logic. The algorithm typically uses uniformly random bits as an auxiliary input to guide its behavior, in the hope of achieving good performance in the “average case” over all possible choices of random bits. Formally, the algorithm’s performance will be a random variable determined by the random bits; thus either the running time, or the output (or both) are random variables.
What is a nondeterministic algorithm?
A nondeterministic algorithm is an algorithm that can exhibit different behaviors on different runs, as opposed to a deterministic algorithm. There are several ways an algorithm may behave differently from run to run.
What can a concurrent algorithm perform?
A concurrent algorithm can perform differently on different runs due to a race condition.
What can a probabalistic algorithm perform?
A probabalistic algorithm’s behaviors depends on a random number generator
The time required to solve a problem usually depends on…
The number of operations the algorithm uses, the hardware and the software can be used as an example.
What is the main advantage of using big-O notation?
One of the advantages of using big-O notation, is that we can estimate the growth of a function without worrying about constant multipliers or smaller order terms. This means that, using big-O notation, we do not have to worry about the hardware and software used to implement an algorithm.
In what way does using big-O notation simplify the analysis?
Using big-O notation, we can assume that the different operations used in an algorithm take the same time, which simplifies the analysis considerably. Big-O notation is used extensively to estimate the number of operations an algorithm uses as its input grows. With the help of this notation, we can determine whether it is practical to use a particular algorithm to solve a problem as the size of the input increases.
Can you use big-O notation to compare two algorithms?
Using big-O notation, we can compare two algorithms to determine which is more efficient as the size of the input grows. For instance, if we have two algorithms for solving a problem, one using 100n2 + 17n + 4 operations and the other using n3 operations, big-O notation can help us see that the first algorithm uses considerably fewer operations when n is large, even though it uses more operations for small values of n, such as n = 10.
What is a useful approach for finding a pair of witnesses?
A useful approach for finding a pair of witnesses is to first select a value of k for which the size of |f(x)| can be readily estimated when x > k and to see whether we can use this estimate to find a value of C for which |f(x)| ≤ C|g(x)| for x > k.