Download presentation

Presentation is loading. Please wait.

Published byCitlali Buntin Modified over 2 years ago

1
Problem Solving Dr. Andrew Wallace PhD BEng(hons) EurIng andrew.wallace@cs.umu.se

2
Overview Breaking and entry How to get away? Which items to steal? Stash the loot

3
Brute Force Simple Start at the beginning Keep working till.. You find a solution! Bang you head against a brick wall long enough, sooner or later the brick wall gives out

4
Brute Force

5
Searching a list Travelling salesman problem Deoxyribonucleic acid Heuristics!

6
Brute Force It can work! Some times it’s the only solution! Problem: Inefficient Can become time consuming

7
Optimal subproblems Optimal solution has optimal subproblem solutions S = {s 1, s 2, s 3, … s n } Optimal sub-structure Greedy algorithms Else Overlapping substructures Dynamic programming

8
Greedy Algorithms Local optimum results in global optimum Problem: Shortest path from A to B Museum Safe House 10 12 9 6 10 12 3 8 2 15

9
Greedy Algorithms Not all local optimal solutions can lead to global optimal solutions Can end up with the worse case If globally optimal can be fast

10
Greedy Algorithms Set of candidate solutions Paths Selection function Which path to choose? End function Are we there yet?

11
Greedy Algorithms A resource Set of agents who want to use the resource No overlaps in time allowed Agents (a)abcdefg Start (s) 1324675 Finish (f) 4566810 a, d, e

12
Greedy Algorithms Earliest finishing time to maximise the number of participants Maximise the remaining time

13
Greedy Algorithms O(n)

14
Greedy Algorithms No back tracking Choices dependent on passed choices but not future choices

15
Dynamic programming Overlapping sub problems Once calculated, save and reuse Dynamic Updates and changes things but not as in dynamic programming languages Programming Filling tables not computer programming

16
Dynamic programming Items Weight Value But we have … Max weight!

17
Dynamic programming Fibonacci sequence F n = F n-1 + F n-2 F 0 = 0, F 1 = 1 and F 2 = 1 F(6) F(4) F(5) F(3) F(4) F(3) F(1)F(2) F(0)F(1) F(2) F(0) F(1) F(2) F(0)F(1) F(2) F(0)F(1) F(2) F(1)F(0) F(1)

18
Dynamic programming Items = {i 1, i 2, i 3 … i n } Weight = {w 1, w 2, w 3 … w n } Value = {v 1, v 2, v 3 … v n } W = max weight we can take

19
Dynamic programming Optimal structure? w = {w 1, w 2 … w j } w = {w 1, w 2 … w j-1 } Overlapping subproblems Compare solution with item to solution without item

20
Dynamic programming If i = 0 or w= 0 If w i > w If i > 0 or w >= w i

21
Dynamic programming O(n)

22
Divide and Conquer Recursion Break the problem reclusively into small problems Preferably evenly Solve the smaller problems Combine together to produce the overall solution

23
Divide and Conquer T(n) = 2T(n/2) + (n) Master method

24
Divide and Conquer

25
Find 90 3345538290120150

26
Divide and Conquer Find 90 Divide into two 3345538290120150

27
Divide and Conquer Find 90 Divide into two And again! 90120150

28
Divide and Conquer Find 90 Divide into two And again! 90

29
Divide and Conquer

30
Problem solving Top down greedy Bottom up dynamic

31
Questions?

Similar presentations

OK

1 Summary: Design Methods for Algorithms Andreas Klappenecker.

1 Summary: Design Methods for Algorithms Andreas Klappenecker.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on trial and error approach Design ppt online Download ppt on indus valley civilization political Ppt on digital multimedia broadcasting Ppt on natural disasters free download Ppt on 600 mw generators Free ppt on save environment Ppt on nitrogen cycle and nitrogen fixation cycle Maths ppt on statistics class 9 Ppt on australian continental divide