Alg 3: Divide & Conquer

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

• O(n²) Every bit in a will need to be multiplied by every bit in b followed by a linear number of shift and addition operations.

Given integers a and b, identify the asymptotic time complexity of computing the product ab using a brute-force approach if a and b are each represented with n bits. • O(n³) • O(n²) • O(n log n)

• O(n^log7) Since Strassen was able to reduce the number of real multiplications per recursive call to seven, solving the resulting recurrence relation produces an asymptotic time complexity of O(n^log7).

Identify the asymptotic time complexity of Strassen's fast matrix multiplication algorithm given two n by n matrices. Assume the logarithmic expressions are of base two. • O(n^log7) • O(n^log6) • O(n^log^8)

• 3 Karatsuba used clever algebraic manipulation to ensure only three real multiplications were computed per recursive call.

Identify the number of real multiplications per recursive call the Karatsuba's algorithm computes. • 4 • 3 • 2

• A Because there is no presorting of coordinates, we must sort x and y-coordinates for each recursive call, which requires O(n log n) time.

Identify the recurrence relation that represents the closest pair of points algorithm without any pre-sorting of coordinates. Assume there are n points on the two-dimensional plane.

• O(n) At the highest recursive level, all n elements of the array will be accessed.

Identify the time complexity of the combine step in the merge-sort algorithm for an array of length n • O(n log n) • O(1) • O(n)

• O(n²) Every recursive call to the fast matrix multiplication algorithm must add or subtract the returned values from the previous recursive call to determine each new position in the matrix product, of which there are n².

Identify this number of addition and/or subtraction operations that occur during the combine phase of Strassen's fast matrix multiplication algorithm. • O(n) • O(n²) • O(n³)

• A This is the only recurrence relation that strictly divides the problem into subproblems with each recursive step and considers all possible non-overlapping subproblems.

Identify which of the following recurrence relations could represent a candidate problem for a divide-and-conquer approach.

• Divide the problem into non-overlapping subproblems until trivial solutions are found, then reconstitute the solutions of the smaller problems into an aggregate solution. The divide-and-conquer technique requires dividing a problem recursively until the smallest possible case is presented, which generally has a trivial solution. Once these solutions are found, they must be combined in such a way that produces a general solution.

Describe the general strategy for the divide-and-conquer technique. • Divide the problem into a sequence of subproblems. Find the optimal solution of the smallest case and build upon this recursively until the optimal solution is found. • Divide the problem into non-overlapping subproblems until trivial solutions are found, then reconstitute the solutions of the smaller problems into an aggregate solution. • Divide the problem into equally sized subproblems, solve each of these subproblems and determine which one of the solutions found is also the general solution.

• O(n)² For a brute-force sort, each element of the array must be compared with every other element of the array, which induces n² - n comparisons.

Identify the asymptotic time complexity for sorting an array of length n using the brute-force method. • O(n) • O(n log n) • O(n)²

• n²/4 The naïve solution would be to consider every point on one side of L and compare each of these points to every other point on the opposite side of L, which creates a total time complexity of n²/4.

The vertical line L divides n points into two halves each of size n/2 and the conquer step of the algorithm returns the closest pair of points on each side of L. The combine step involves comparing points on either side of L to determine whether the closest pair of points span both sides of L. If we are not careful about limiting the number of comparisons made during the combine step, what will be the time complexity of this step? • n • n² • n²/4


Ensembles d'études connexes

Chapter 31: Assessment and Management of Patients With Hypertension

View Set

Maternity Week 2 TB CH 3, 10, 11, 12

View Set

Life Insurance Policies - Provisions, Options and Riders

View Set

Chapter 13: Abdomen and Gastrointestinal System

View Set

Speech - Chapter 10 - Introduction/Conclusion

View Set

1630 - Founding of Massachusetts Bay Colony

View Set