Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exhaustion, Branch and Bound, Divide and Conquer.

Similar presentations


Presentation on theme: "Exhaustion, Branch and Bound, Divide and Conquer."— Presentation transcript:

1 Exhaustion, Branch and Bound, Divide and Conquer

2 Bin packing Maximum Consecutive Sum Fast Exponentiation Closest Pair

3 窮舉 / 窮尋 / 暴力法 Also called Brute Force Anyway it is not about violence...

4 Why Exhaustion Sometimes it’s the only way out. Case Study 1 Irreversible Transform Given a transform H, you can calculate y = H(x) But given y, you cannot easily calculate x such that y = H(x), we call H is irreversible Given y, tell me how many x can be transformed to y

5 Why Exhaustion Simple Less Error Prone … But that may take a LONG TIME.

6 Not that simple The way you exhaust matters Case Study 2 Narrow Range Broadband Given all clients’ positions as well as the profits that can be made from each of them You can only setup one server station with limited transmission distance Give the best possible position and the profit for the company

7 Case Study 2 Give the best possible position and the profit for the company Any definite answer, first? The more the clients it covers, the better? Map size: at most 100 x 100 (w x h) Number of clients: at most 1000 (n) Maximum distance: 200 (d) Manhatten Distance:

8 Case Study 2 Give the best possible position and the profit for the company Solution 1 Each position can be the best For each position Find from its reachable distance Add profit if that position is a client Complexity?

9 Case Study 2 Give the best possible position and the profit for the company Solution 1 Complexity? Can we be faster?

10 Case Study 2 Give the best possible position and the profit for the company Solution 2 A client is served if a server can reach it within d units Similarly, if a client can reach the server d units, it is served By exploiting the fact that distance is symmetric, one can achieve an algorithm Any faster algorithm?

11 Summary If you cannot figure out fast way to solve a given problem (may or may not exist), try brute force For small case (usually 30%~50%), they are designed for brute force purposes Exhaust in a smart way

12 Tricks Pre-process Memorization MRV (Minimum Remaining Values) –Aka. MCV (Most Constrained Variables) LCV (Least Constraining Value)

13 Branch and Bound Basically like exhaustion Try to be faster –Prune sub-optimal searching early

14 Branch and Bound Idea: “Estimate” the best solution of the current Search Tree with a heuristic function If the estimation says this search tree will not produce better result, give up on it… Well… is it possible that we miss the optimal solution if we give up on some search tree?

15 Branch and Bound An admissible heuristic function is a heuristic function that never over- estimates It can be proved that if a admissible heuristic function is used, the result is always optimal

16 Examples Bin Packing

17 Divide and Conquer Three steps – Divide, Conquer, and Combine –Divide: Breaks the problem into some sub-problems –Conquer: Solve individual sub-problems –Combine: Use solutions to sub-problems to construct a solution to the original problem Question: How are sub-problems solved?

18 Examples (D&C) Finding Max and Min in a list of numbers Merge Sort Quick Sort L-Block

19 Mergesort

20 Maximum Consecutive Sum Given a sequence of numbers, find a consecutive subsequence, such that its total sum is largest.

21 Fast Exponentiation

22

23 Given a plane of points, find the distance of the closest pair Closest Pair

24 Closet Pair

25 Appendix Complexity: Master Theorem


Download ppt "Exhaustion, Branch and Bound, Divide and Conquer."

Similar presentations


Ads by Google