{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lec09_10_Divide&amp;Conquer

# Lec09_10_Divide&amp;Conquer - Algorithm Design Strategy...

This preview shows pages 1–11. Sign up to view the full content.

Algorithm Design Strategy Divide and Conquer Revisit Notes on Brute-force approach

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
More example by using Divide and Conquer method Introduction of D&C Approach Finding closest pair of points Quicksort Matrix Multiplication Algorithm Large Integer Multiplication Convex Hull-problem
Divide and Conquer Approach Concept: - D&C is a general strategy for algorithm design. It involves three steps: (1) Divide an instance of a problem into one or more smaller instances (2) Conquer (solve) each of the smaller instances. Unless a smaller instance is sufficiently small, use recursion to do this (3) If necessary, combine the solutions to the smaller instances to obtain the solution to the original instances (e.g., Mergesort) Approach: - Recursion (Top-down approach)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example 1 Binary search in a sorted array with size n Worst case time complexity in the recursive binary search: W(n) = W(n/2) + 1 W(1) = 1 Solve the recurrence, and obtain: W(n) = lg(n) +1 Θ (lg n)
Example 2 Finding the closest pair of points - Task: solve the problem of finding the closest pair of points in a set of points. The set consists of points in two dimensional plane defined by both an X and a Y coordinate. - Given a set P of N points, find p. q P, such that the distance d(p, q) is minimum - Application: - traffic control systems: A system for controlling air or sea traffic might need to know which two vehicles are too close in order to detect potential collisions. - Computational geometry

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example 2 Finding the closest pair of points - The "closest pair" refers to the pair of points in the set that has the smallest Euclidean distance, Distance between points p1=(x1,y1) and p2=(x2,y2) - If there are two identical points in the set, then the closest pair distance in the set will obviously be zero. 2 2 1 2 2 1 2 1 ) ( ) ( ) , ( y y x x p p D - + - =
Example 2 (brute-force approach) Find the two closest points in a set of Find the two closest points in a set of n n points (in the two- points (in the two- dimensional Cartesian plane). dimensional Cartesian plane). Brute-force algorithm Brute-force algorithm Compute the distance between every pair of distinct points Compute the distance between every pair of distinct points and return the indexes of the points for which the distance is and return the indexes of the points for which the distance is the smallest. the smallest.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Closed pair problem (Brute-force approach)
Example 2 Finding the closest pair of points - Brute-force algorithm: Find all the distances D(p, q) and find the minimum distance Time complexity: O(n 2 )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Notes on Brute-force approach A straightforward approach, usually based directly on the A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved problem’s statement and definitions of the concepts involved Examples: Examples: Computing Computing an an ( ( a a > 0, > 0, n n a nonnegative integer) a nonnegative integer) Computing Computing n n !
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 48

Lec09_10_Divide&amp;Conquer - Algorithm Design Strategy...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online