Chapter 5: Divide and Conquer

¡Supera tus tareas y exámenes ahora con Quizwiz!

What's the main approach to substituting a solution into the mergesort recurrence?

If we have a guess for the running time that we want to verify, we can do so by plugging it into the mergesort recurrence.

What defines an inversion?

We say that two indices i < j form an inversion if a_i > a_j, that is, if the two elements a_i and a_j are "out of order."

What's the main approach to unrolling the mergesort recurrence?

1. Analyze the first few levels, looking at the time spent at those levels. I.e. Level 0: cn, Level 1: cn/2 + cn/2 = cn total, Level 2: 4(cn/4) = cn total, etc. 2. Identify a pattern, i.e. level j contributes a total of at most 2^j(cn/2^j) = cn to the total running time. 3. Sum over all levels of the recursion.

What are the two basic ways to go about solving a recurrence?

1. Unrolling (recursion tree) 2. Substitution (induction) (Kleinberg and Tardos 211, 5.1: A First Recurrence: The Mergesort Algorithm)

How would you describe the abstract behavior of many common divide-and-conquer algorithms?

Divide the input into two pieces of equal size; solve the two subproblems on these pieces seperateley by recursion; and then combine the two results into an overall solution, spending only linear time for the initial division and final recombining (Kleinberg and Tardos 210, 5.1: A First Recurrence: The Mergesort Algorithm).

What is the recurrence relation for Mergesort?

T(n) ≤ 2T(n/2) + cn when n > 2, and T(2) ≤ c Any function T(.) satisfying this is bounded by O(nlogn), when n > 1. (Kleinberg and Tardos 211, 5.1: A First Recurrence: The Mergesort Algorithm)

What is the base case for Mergesort?

We will assume that once the input has been reduced to size 2, we stop the recursion and sort the two elements by simply comparing them to each other (Kleinberg and Tardos 210, 5.1: A First Recurrence: The Mergesort Algorithm).


Conjuntos de estudio relacionados

MGMT 310A Exam 2 Review Chapter 7

View Set

cells, cell membranes, & signal transduction (6,7,&11)

View Set

Chapter 8 Psychology of Adjustment

View Set