Chapter 2 Flashcards
Define Efficiency
An algorithm is efficient if it has a polynomial running time.
Define Polynomial Time
a polynomial-time algorithm is one whose running time T(n) is O(n^d) for some constant d, where d is independent of the input size.
What is the asymptotic upper bound for a polynomial?
Let f be a polynomial of degree d, in which the coefficient ad is positive. Then f = O(n^d).
What is the asymptotic upper bound for a logarithm?
For every b>1 and every x>0, we have logb n=O(n^x).
What is the asymptotic upper bound for an exponent?
For every r>1 and every d>0, we have n^d=O(r^n).
What is a common trait among linear time algorithms?
They can be linear time because they spend a constant time on each input received or for subtler reasons (see explanation of merging 2 sorted lists in textbook)
What is a common trait among O(n log n) time algorithms?
it is the running time of any algorithm that splits its input into two equal-sized pieces, solves each piece recursively, and then combines the two solutions in linear time.(i.e MergeSort)
Can also be encountered when the most expensive step of an algorithm is to sort input.
What is a common trait among O( n^2) time algorithms?
Looping through 2 loops
What is a common trait among O(log n) time algorithms?
O(log n) arises as a time bound whenever we’re dealing with an algorithm that does a constant amount of work in order to throw away a constant fraction of the input.