Exam 3: A: Algorithms

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

Prove that 5x4+2x31 is Θ(x4)5 x ^ { 4 } + 2 x ^ { 3 } - 1 \text { is } \Theta \left( x ^ { 4 } \right)

Free
(Short Answer)
5.0/5
(43)
Correct Answer:
Verified

5x4+2x315 x ^ { 4 } + 2 x ^ { 3 } - 1 is O(x4)O \left( x ^ { 4 } \right) since 5x4+2x315x4+2x47x4\left| 5 x ^ { 4 } + 2 x ^ { 3 } - 1 \right| \leq \left| 5 x ^ { 4 } + 2 x ^ { 4 } \right| \leq 7 \left| x ^ { 4 } \right| (if x1)\left. x \geq 1 \right) . Also, x4x ^ { 4 } is O(5x4+2x31O \left( 5 x ^ { 4 } + 2 x ^ { 3 } - 1 \right. ) since x45x4+x35x4+2x31\left| x ^ { 4 } \right| \leq \left| 5 x ^ { 4 } + x ^ { 3 } \right| \leq \left| 5 x ^ { 4 } + 2 x ^ { 3 } - 1 \right| (if x1x \geq 1 ).

assume that the number of multiplications of entries used to multiply a p × q and a q × r matrix is pqr. -What is the best order to form the product ABC if A, B and C are matrices with dimensions 2 × 5, 5 × 7 and 7 × 3, respectively?

Free
(Essay)
4.9/5
(33)
Correct Answer:
Verified

(AB)C uses 2 · 5 · 7 + 2 · 7 · 3 = 112 multiplications, fewer than A(BC), which uses 5 · 7 · 3 + 2 · 5 · 3 = 135.

find the "best" big-O notation to describe the complexity of the algorithm. Choose your answers from the following: 1,log2n,n,nlog2n,n2,n3,,2n,n!1 , \log _ { 2 } n , n , n \log _ { 2 } n , n ^ { 2 } , n ^ { 3 } , \ldots , 2 ^ { n } , n ! -The worst-case analysis of a linear search of a list of size n (counting the number of comparisons)

Free
(Short Answer)
4.7/5
(44)
Correct Answer:
Verified

n

find the best big-O function for the function. Choose your answer from among the following:  1, log2n,n,nlog2n,n2,n3,,2n,n!\text { 1, } \log _ { 2 } n , n , n \log _ { 2 } n , n ^ { 2 } , n ^ { 3 } , \ldots , 2 ^ { n } , n ! - 32n44n2n33n\frac { 3 - 2 n ^ { 4 } - 4 n } { 2 n ^ { 3 } - 3 n }

(Short Answer)
4.8/5
(29)

Describe an algorithm that takes a list of n integers a1, a2, . . . , an and finds the number of integers each greater than five in the list.

(Short Answer)
4.8/5
(36)

find the "best" big-O notation to describe the complexity of the algorithm. Choose your answers from the following: 1,log2n,n,nlog2n,n2,n3,,2n,n!1 , \log _ { 2 } n , n , n \log _ { 2 } n , n ^ { 2 } , n ^ { 3 } , \ldots , 2 ^ { n } , n ! -The number of print statements in the following:  find the best big-O notation to describe the complexity of the algorithm. Choose your answers from the following:  1 , \log _ { 2 } n , n , n \log _ { 2 } n , n ^ { 2 } , n ^ { 3 } , \ldots , 2 ^ { n } , n !  -The number of print statements in the following:

(Short Answer)
4.8/5
(33)

List all the steps that the naive string matcher uses to match the pattern xy in the text yxyxxy.

(Essay)
4.9/5
(40)

Use the definition of big-O to prove that 13+23++n3 is O(n4)1 ^ { 3 } + 2 ^ { 3 } + \cdots + n ^ { 3 } \text { is } O \left( n ^ { 4 } \right) \text {. }

(Short Answer)
4.8/5
(32)

find the "best" big-O notation to describe the complexity of the algorithm. Choose your answers from the following: 1,log2n,n,nlog2n,n2,n3,,2n,n!1 , \log _ { 2 } n , n , n \log _ { 2 } n , n ^ { 2 } , n ^ { 3 } , \ldots , 2 ^ { n } , n ! -An iterative algorithm to compute n!, (counting the number of multiplications)

(Short Answer)
4.7/5
(29)

Use the definition of big-O to prove that 3n84n32n1\frac { 3 n - 8 - 4 n ^ { 3 } } { 2 n - 1 } is O(n2)O \left( n ^ { 2 } \right)

(Essay)
4.8/5
(31)

Suppose you have two different algorithms for solving a problem. To solve a problem of size n, the first algorithm uses exactly nnn \sqrt { n } operations and the second algorithm uses exactly n2lognn ^ { 2 } \log n operations. As n grows, which algorithm uses fewer operations?

(Essay)
4.9/5
(36)

List all the steps the binary search algorithm uses to search for 27 in the following list: 5, 6, 8, 12, 15, 21, 25, 31.

(Essay)
4.9/5
(33)

Use the definition of big-O to prove that 12+23+34++(n1)n is O(n3)1 \cdot 2 + 2 \cdot 3 + 3 \cdot 4 + \cdots + ( n - 1 ) \cdot n \text { is } O \left( n ^ { 3 } \right)

(Short Answer)
4.9/5
(37)

Describe an algorithm that takes a list of n integers (n1)( n \geq 1 ) and finds the average of the largest and smallest

(Essay)
4.9/5
(30)

find the "best" big-O notation to describe the complexity of the algorithm. Choose your answers from the following: 1,log2n,n,nlog2n,n2,n3,,2n,n!1 , \log _ { 2 } n , n , n \log _ { 2 } n , n ^ { 2 } , n ^ { 3 } , \ldots , 2 ^ { n } , n ! -An algorithm that finds the average of n numbers by adding them and dividing by n

(Short Answer)
4.9/5
(33)

assume that the number of multiplications of entries used to multiply a p × q and a q × r matrix is pqr. -What is the most efficient way to multiply the matrices A1, A2, A3 of sizes 10 × 50, 50 × 10, 10 × 40?

(Short Answer)
4.9/5
(29)

Give a big-O estimate for the number of operations (where an operation is an addition or a multiplication) used in this segment of an algorithm: Give a big-O estimate for the number of operations (where an operation is an addition or a multiplication) used in this segment of an algorithm:

(Short Answer)
4.9/5
(31)

find the "best" big-O notation to describe the complexity of the algorithm. Choose your answers from the following: 1,log2n,n,nlog2n,n2,n3,,2n,n!1 , \log _ { 2 } n , n , n \log _ { 2 } n , n ^ { 2 } , n ^ { 3 } , \ldots , 2 ^ { n } , n ! -An algorithm that prints all bit strings of length n.

(Short Answer)
4.9/5
(35)

Arrange the functions n3/2,log(nn),(n100)n and log(n!)n ^ { 3 / 2 } , \log \left( n ^ { n } \right) , \left( n ^ { 100 } \right) ^ { n } \text { and } \log ( n ! ) in a list so that each function is big-O of the next function.

(Short Answer)
4.8/5
(46)

List all the steps that insertion sort uses to sort 8, 20, 13, 16, 9

(Essay)
4.8/5
(46)
Showing 1 - 20 of 54
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)