E N D
1. Design and Analysis of Algorithms Chapter 4 1 CSCE 310: Data Structures & Algorithms
2. Design and Analysis of Algorithms Chapter 4 2 Divide and conquer examples
Closest-pair problem
Presentation Slides by Tsvika Klein
Convex-hull problem
Presentation slides by Joo Comba
3. Design and Analysis of Algorithms Chapter 4 3 QuickHull Algorithm Inspired by Quicksort, it compute Convex Hull:
Assume points are sorted by x-coordinate values
Identify extreme points P1 and P2 (part of hull)
Compute upper hull (Lower hull computation is similar):
find point Pmax that is farthest away from line P1P2
compute the hull of the points to the left of line P1Pmax
compute the hull of the points to the left of line PmaxP2
4. Design and Analysis of Algorithms Chapter 4 4 Efficiency of QuickHull algorithm Finding point farthest away from line P1P2 can be done in linear time
This gives same efficiency as quicksort:
Worst case: T( n2)
Average case: T( n log n)
If points are not initially sorted by x-coordinate value, this can be accomplished in T( n log n) no increase in asymptotic efficiency class
Other algorithms for convex hull:
Grahams scan
DCHull
also in T( n log n)
5. In-Class Exercise 1 A k-way merge operation. Suppose you have k sorted arrays, each with n elements, and you want to combine them into a single sorted array of kn elements.
A) Heres one strategy: Using the merge procedure from Section 4.1, merge the first two arrays, then merge in the third, then merge in the fourth, and so on. What is the time complexity of this algorithm, in terms of k and n?
B) Give a more efficient solution to this problem, using divide-and-conquer. Design and Analysis of Algorithms Chapter 4 5
6. In-Class Exercise 2 An array A[1 n] is said to have a majority element if more than half of its entries are the same. Given an array, the task is to design an efficient algorithm to tell whether the array has a majority element, and, if so, to find that element. The elements of the array are not necessarily from some ordered domain like the integers, and so there can be no comparisons of the form is A[i] > A[j]?. (Think of the array elements as GIF files, say.) However you can answer questions of the form: is A[i] = A[j]? in constant time. Design and Analysis of Algorithms Chapter 4 6
7. Reading List Chapter 5.1 5.2, 5.3 & 5.4 Design and Analysis of Algorithms Chapter 4 7