{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# DA15 - Algorithm Design Techniques Brute force...

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

B.B. Karki, LSU 0.1 CSC 3102 Algorithm Design Techniques Brute force Divide-and-conquer Decrease-and-conquer Transform-and-conquer Space-and-time tradeoffs Dynamic programming Greedy techniques

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

View Full Document
B.B. Karki, LSU 0.2 CSC 3102 Brute Force Simplest approach: just do it Selection sort: n 2 String matching: mn Convex hull problem: n 3 Exhaustive search Traveling salesman problem: ( n -1)!/2 Knapsack problem: 2 n Assignment problem: n !
B.B. Karki, LSU 0.3 CSC 3102 Divide-and-Conquer

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

View Full Document
B.B. Karki, LSU 0.4 CSC 3102 Basic Idea Divide-and-conquer algorithm works as follows: A problem’s instance is divided into several smaller instances of the same problem, ideally of about the same size. The smaller instances are solved typically recursively. Sometimes, a different algorithm is applied when instances become small enough. The solutions obtained for the smaller instances are combined to get a solution to the original problem. No necessary to combine in some cases. Divide-and-conquer technique is ideally suited for parallel computers, in which each subproblem can be solved simultaneously by its own processors. Common case: Dividing a problem into two smaller problems. problem of size n subproblem 1 of size n/2 subproblem 2 of size n/2 solution to subproblem 1 solution to subproblem 1 solution to the original problem
B.B. Karki, LSU 0.5 CSC 3102 Master Theorem A problem’s instance of size n is often divided into two instances of size n /2. In general, an instance of size n can be divided into several instances of size n / b , with a of them needing to be solved ( a 1, b 2) . If n is a power of b , say, n = b k , the recurrence relation for running time is T(n) = a T(n/b) + f(n), called the general divide-and-conquer recurrence Where f ( n ) is a function that accounts for the time spent on dividing the problem into smaller ones and on combining their solutions. Master Theorem: If f ( n ) Θ ( n d ) where d 0 in recurrence equation, then Analogous results hold for the big-oh and big-omega notations. It can only establish solution’s order of growth to within an unknown multiplicative constant but solving a recurrence equation with a specific condition can actually yield an exact answer. T ( n ) Θ ( n d ) a < b d Θ ( n d log n ) a = b d Θ ( n log b a ) a > b d

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

View Full Document
B.B. Karki, LSU 0.6 CSC 3102 Mergesort Mergesort sorts a given array by dividing it into two halves, sorting each of them recursively, and then merging the two smaller sorted arrays into a single sorted one. See Figure 2 of the text book for the operation of the algorithm on the list 8, 3, 2, 9, 7, 1, 5, 4.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 16

DA15 - Algorithm Design Techniques Brute force...

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

View Full Document
Ask a homework question - tutors are online