chapter 3
Drag and drop the total number of multiplications against the corresponding ways of multiplying the matrices A, B, C, and D with dimensions 20 × 10, 10 × 30, 30 × 40, and 40 × 15 respectively.
((AB)C)D matches Choice 42,000 (A(BC))D matches Choice 32,000 A((BC)D) matches Choice 21,000 (AB)(CD) matches Choice 33,000 A(B(CD)) matches Choice 25,500
Match each sequence with the position of its first term that is out of increasing order.
1 5 78 99 101 202 400 matches Choice Sequence is in increasing order 5 2 7 90 85 80 72 matches Choice second position 5 6 9 10 14 21 20 matches Choice seventh position 3 7 10 9 8 14 17 matches Choice fourth position 5 77 25 45 22 94 58 99 matches Choice third position
Match the list on the left with the possible number of times the binary search algorithm splits the list when searching for a term in the list.
1, 7, 9 matches Choice 1 or 2 1, 29, 34, 50 matches Choice 2 1, 30, 50, 55, 60, 77 matches Choice 2 or 3 1, 2, 34, 35, 45, 55, 67, 69, 70, 74, 75, 78, 101, 105, 109, 119 matches Choice 4 5 matches Choice 0
Drag and drop the description of what it does against the corresponding algorithms described in pseudocode.
1. The algorithm finds the maximum value in the input sequence 2. his algorithm finds the minimum value in the input sequence. 3. is algorithm finds the sum of all of the integers in the input sequence 4. is algorithm finds the average of the integers in the input sequence
Put the following steps in order to perform a worst-case analysis of bubble sort.
1. bubble 2. on the 3. the total number 4. hence,
Arrange the steps of the binary search algorithm, to search for the integer x in the list a1, a2,⋅⋅⋅, an, where a1 < a2 < · · · < an.
1. compare 2. if x>a 3. other 4. using 5. the pre 6. if x is equal
Order the steps to form a proof that f(n) = 1 + 2 + 3 + ... +n is Ω(n2).
1. f(n) 2. >_[n/2 3.=(n- 4.>_(n/2 5.=n^2
Order the following steps to produce an average-case analysis of the linear search algorithm in terms of the average number of comparisons used. You can assume the integer x is in the list.
1. if x 2. the average 3. this can 4. this can =n+2 5. hence
Put these steps in order of an algorithm that finds the largest value in a finite sequence of integers.
1. set 2.compare 3. if the 4. repeat 5. the tempo
Order the following steps of a trace of the linear search algorithm used to search for 13 in the list 14, 13, 12. Place the first step at top.
1. set I to 1 2. compare 1 with 13 3. set I to 12 4. compare the value 5. compare the location 2 with 6. report
Order the following steps of a trace of the max algorithm with input 12, 13, 14, 11.
1. set max 2. compare 13 13 3. 14 14 4. 11 5. report
Find the highest number of multiplications of integers that may be needed to multiply the matrices A, B, and C, where A is 20×10, B is 10×30, and C is 30×40, all with integer entries. This results from the least efficient ordering of operations.
30000
Which of these statements are true regarding big-O estimates of some important functions?
3x4 + 1000x is O(x4). n3 is not O(n2).
The number of character comparisons used by the naive string matcher to look for the pattern of in the text love is
4
Using the greedy algorithm for scheduling talks, find the greatest number of talks that can be scheduled if the starting and ending times of the possible talks are 8:00-8:50, 8:30-9:00, 8:55-9:45, 9:15-9:55, 10:00-10:30, 10:15-10:25, 10:30-10:55, 11:00-11:35, 10:55-11:25, 10:45-11:30
5
Which pairs of numbers C, k are witnesses to the fact that x2 + 3x is O(x2)?
C= 4, k = 2 C = 5, k = 1 C = 4, k = 1
Which pairs of numbers C, k are witnesses to the fact that x2 + 3x is O(x2)?
C= 5, k = 1 C = 4, k = 2 C = 4, k = 1
Which of these statements about the binary search algorithm are true?
The number of comparisons performed by the algorithm when given a search term that is in the sequence is independent of the search term. For all search terms and all sequences, the binary search algorithm continues splitting the sequence until it only contains one term. Given a sequence, each integer from 1 to the size of the sequence can be the output of the binary search algorithm for some search term.
Match the concept on the left with the definition on the right.
Time complexity matches Choice The number of operations required to solve a problem of a particular size Space complexity matches Choice The amount of computer memory required to solve a problem of a particular size Worst-case time complexity matches Choice The largest number of operations needed to solve a problem of a particular size Average-case time complexity matches Choice The average number of operations used to solve the problem over all possible inputs of a given siz
What steps need to be done to show that the algorithm for finding the maximum element in a finite sequence is correct?
We must show that when the algorithm terminates, the value of the variable max equals the maximum term of the sequence.
Consider the letters k, m, h, g, e, a, b, and d. "kmhgeabd" is a character string made from the given letters whose characters are in the given order. The string made from the given letters whose characters are in increasing alphabetical order is
abdeghkm or "abdeghkm"
Which of the following statements apply to greedy algorithms?
to show that a greedy algorithm does not always produce an optimal solution, a counterexample is sufficient. They select the best choice at each step according to some criteria. They solve optimization problems. A proof is required to show a particular greedy algorithm always produces an optimal solution.
What steps need to be done to show that the algorithm for finding the maximum element in a finite sequence is correct?
we must show that when the algorithm terminates, the value of the variable maxequals the maximum term of the sequence.
Which is the most efficient method to find the multiplication of the matrices A of order 3 × 2, B of order 2 × 1, and C of order 1 × 5.
(AB)C
Determine the number of bit operations used to compute the boolean product of A and B, where Aand B are 2×2 zero-one matrices.
16
Match the properties of an algorithm in the left column with their corresponding descriptions on the right.
correctness matches Choice Produces the right output values for each set of input values Definiteness matches Choice Steps are precisely defined Finiteness matches Choice Always produces the output after a finite number of steps Effectiveness matches Choice Each step can be performed exactly and in a finite amount of time Generality matches Choice Is applicable for all problems of the desired form, not just for a particular set of input values Input matches Choice Operates on values from a specified set Output matches Choice A solution of the proper form is produced for each set of input values
Match the statement on the left with correct conditions on the right.
f(x) is O(g(x)) matches Choice There are constants C and k such that |f(x)| ≤ C|g(x)| when x > k. f(x) is Ω(g(x)) matches Choice There are constants C and k such that |f(x)| ≥ C|g(x)| when x > k f(x) is Θ(g(x)) matches Choice There are constants C1, C2, and k such that C1|g(x)| ≤ |f(x)| ≤ C2|g(x)| when x > k.