Presentation is loading. Please wait.

Presentation is loading. Please wait.

Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math.

Similar presentations


Presentation on theme: "Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math."— Presentation transcript:

1 Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math and number theory July 15: Coordinate geometry July 22: Black rain? July 29: Graph, MST, bipartite matching Aug 5: Black rain? Aug 12: Individual contest 1 Aug 19: Individual contest 2 Aug 26: Dynamic programming Sep 2: Revision Sep 9: Team formation test

2 Recursion 1. Do something 2. Repeat Any algorithm that have the above format is using "recursion". Properties: Easy to design and write Tend to be slow (because trying all possibilities)

3 Greedy algorithms 1. Make a choice that looks good (greedy choice) 2. Repeat if the problem is not yet solved Easy to design and write Tend to be fast (because make only 1 greedy choice) Finding the correct greedy choice and proving the correctness is usually hard.

4 Dynamic programming The optimal solution easier problem

5 Example 1. Magic bubbles Given a sequence of n bubbles with colors Red, Green and Blue and a table of possible transformations. Determine whether we can form a bubble with targeted color.

6 Dynamic programming Solution for [1,n] [1,1] [1,2] [2,3] [2,4] [1,n] [3,4] [2,2]

7 Example 2. Cutting Sticks (UVA10003)

8 Dynamic programming Solution for [1,n] [1,1] [2,3] [1,2] [2,2] [3,4] [4,4] [3,3] Optimal substructures [1,3] Overlapping subproblems

9 Example 3. Matrix multiplication

10 Example 4. Longest common subsequence

11 Example 5. Edit distance

12 Example 6. Prize collection

13 Example 7. Longest increasing subsequence

14 Example 8. Subset sum

15 Example 9. Optimal binary search tree

16 Example 10. Knapsack problem


Download ppt "Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math."

Similar presentations


Ads by Google