Exam 1
1^10 + 2^10 + ... + n^10~ _________
(n^11) / 11
order of best, average, worse of BinarySearch
1,logn,logn
order of best, average, worse of LinearSearch
1,n,n
n + 2n^2 + ... + 10n^10~ ___________
10n^10
Worst-case complexity of BinarySearch is W(n) ~ _________
2log₂(n) (not to be confused with the order to worst complexity!!!!)
order of best, average, worse of Towers
2ⁿ,2ⁿ,2ⁿ
Solve the recurrence relation f(n) = f(n - 1) + 3 init. cond. f(0) = 0.
3n
The smallest worst case complexity for computing the maximum and minimum elements in an list of even size n is:
3n/2 -2
1 + 2 + 3 + ... + 999
499500
The number of leaf nodes of a 2-tree with 101 nodes:
51
An efficient algorithm for polynomial evaluation is:
Algorithm based on Horner's rule
Define what is meant by the best-case complexity B(n) of an algorithm.
Book Def = the function B(n) such that B(n) equals the minimum value of t(I), where I varies over all inputs on size n. (pg 34) My Def = the case in which the algorithm (under optimal conditions for the specific algorithm) preforms with the least amount of computations to solve a problem
Define what is meant by the worst-case complexity W(n) of an algorithm.
Book Def = the function W(n) such that W(n) equals the maximum value of t(I) where I varies over all inputs of size n (pg 34) My Def = the case in which the algorithm preforms the maximum number of possible computations to solve the problem.
The worst-case complexity of Euclid's algorithm for gcd(a,b) occurs when a and b are:
Consecutive Fibonacci numbers
Analyze the worst-case behavior W(n) of Quicksort.
DONT KNOW
Define what is meant by exponential order
DONT KNOW
An efficient algorithm for computing the greatest common divisor of two integers is:
Euclid's Algorithm
show the action of Euclid's GCD algorithm on a = 111 & b = 141
GCD = 3
H(n) = 1 + 1/2 + 1/3 + ... + 1/n what does this equal
H(n)∼ln(n)
Question 10 on the detailed response. Its about recurrence relations
I HAVE NO CLUE
Which of the following sorting algorithms is not in-place:
Merge Sort
Is 1 + 2 + 3 + ... + n ∈ O( n )?
NO, using pascals law of addition [n(n+1)]/2 so O(n^2)
P(n) = a_κ*n^κ+...+a_1*n+a_0 with a_κ>0 what does this equal
P(n) ∼ a_k*n^k
x¹⁰⁸ left to right
PG 10 texbook
Give pseudocode for the algorithm for evaluating a polynomial of degree n using Horner's rule, involving only n multiplications and n additions.
PG 20
Give pseudo code for Quicksort (Do NOT include pseudo code for Partition).
PG 52
Prove O(n^k)⊂O(a^n)
PG 92
Prove (using limits) that O(n^k) ⊂ O(e^n) for any positive constant k
PG 92 use L'hopital's rule
For k a constant, prove that log n! = log 1+ log 2 + ... + log n = Θ(n log n).
PG 96
Prove that H(n) ~ ln n, where H(n) = 1 + ½ + 1/3 + ... + 1/n.
PG 96-97 but i don't understand it
An sorting algorithm that is not comparison-based:
Radix Sort
what best describes an algorithm
Sequence of steps for solving a problem
The worst-case complexity of Quicksort occurs when:
The list is already sorted
Binary Search assumes as a precondition that:
The list is sorted
The formal definition of an algorithm utilizes concept of a ___________
Turing Machine
An algorithm with worst-case complexity W(n) is said to be polynomial-time if
W(n) ∈ O(n^k) for some constant k
Parenthesize to illustrate action of Horner's rule: 2x^5 + 6x^3- 44x^2 + x + 5
[([(2x+0)x+6]x-44)x+1]x +5
Solve the recurrence relation f(n) = f(n - 1) + n init. cond. f(1) = 0.
[n(n-1)]/2 (this needs to be checked) possibly [(n-1)(n-2)]/2
S(n,k) = 1^k + 2^k + ... + n^k what does this equal
[n^(k+1)] / (k+1)
Show that the number of decimal digits of n is approximately log₁₀n
follow same logic as seen on PG 12 (Figure 1.2)
Give recurrence relation for Euclid's GCD algorithm:
gcd(a,b) = gcd(b,a mod b) initial condition -> gcd(a,0) = a
WTF IS INDUCTION?
i don't know, help me
Define what is meant by the average complexity A(n) of an algorithm.
if the probability distribution for any given input is equally likely. then the average complexity is as simple as summing the complexity's and dividing by the number summed (aka average)
Prove that 1 + 2 + ... + n = n(n + 1)/2 ∈ Θ(n^2)
l'hopital's rule and a sprinkle of Ratio Limit Theorem
Prove the average complexity 2n ln n of Quicksort is of smaller order than the average complexity n^2/4 - n/4 of Insertionsort, i.e., show O(2n ln n) ⊂ O(n^2/4 - n/4).
l'hopital's rule basically showing n^2 is bigger than nlogn
1/2+ 1/3 + ... 1/(2n) ~ _________
ln(2n) -1
The number of binary digits of an integer n is approximately equal to:
log₂(n)
f(n) satisfies the recurrence relation f(n) = f(n/2) +1, inti. cond. f(1) = 0. Then f(n) has order:
log₂(n)
The depth of a complete tree on n nodes is approximately equal to:
log₂n
order of best, average, worse of HornerEval
n,n,n
order of best, average, worse of Max,Min,MAXMIN
n,n,n
order of best, average, worse of InsertionSort
n,n²,n²
log (n!) ∈ Θ (___________)
nlog(n)
order of best, average, worse of HeapSort
nlogn,nlogn,nlogn
order of best, average, worse of MergeSort
nlogn,nlogn,nlogn
order of best, average, worse of QuickSort
nlogn,nlogn,n²
Solve the recurrence relation f(n) = 3f(n/3) + n init. cond. f(1) = 0 (assume n = 3^k)
nlog₃n
Prove (using limits) that O(ln n) ⊂ O(n)
use L'hopital's rule
Let P(n) be a polynomial of degree k whose degree k term as coefficient a_k. Prove that P(n) ~ a_k*n^k
use l'hopitals rule
Assuming a uniform distribution the worst case and average complexities of Insertion sort are :
~n²/2 and ~n²/4
The smallest worst-case complexity of a comparison-based sorting algorithm is:
Θ (n log n)
Mergesort has best, average and worst case complexities, respectively, given by:
Θ(n log n) , Θ(n log n), Θ(n log n)
Quicksort has best, average and worst case complexities, respectively, given by:
Θ(n log n) , Θ(n log n), Θ(n²)
Linear Search and Interpolation Search have worst-case complexities, respectively:
Θ(n), Θ(n)
what is the lower bound for any worst case complexity W(n) of any comparison-based sorting algorithm
Ω(nlogn)