Problem Solving Dr. Andrew Wallace PhD BEng(hons) EurIng

Slides:



Advertisements
Similar presentations
Dynamic Programming 25-Mar-17.
Advertisements

Algorithm Design Techniques
Dynamic Programming Introduction Prof. Muhammad Saeed.
Algorithm Design approaches Dr. Jey Veerasamy. Petrol cost minimization problem You need to go from S to T by car, spending the minimum for petrol. 2.
Dynamic Programming (DP)
Dynamic Programming.
Algorithm Design Methodologies Divide & Conquer Dynamic Programming Backtracking.
Dynamic Programming An algorithm design paradigm like divide-and-conquer “Programming”: A tabular method (not writing computer code) Divide-and-Conquer.
Dynamic Programming Nithya Tarek. Dynamic Programming Dynamic programming solves problems by combining the solutions to sub problems. Paradigms: Divide.
Types of Algorithms.
Analysis of Algorithms
Algorithms + L. Grewe.
Greedy Algorithms Be greedy! always make the choice that looks best at the moment. Local optimization. Not always yielding a globally optimal solution.
Overview What is Dynamic Programming? A Sequence of 4 Steps
Dynamic Programming.
Introduction to Algorithms
Greedy Algorithms Basic idea Connection to dynamic programming Proof Techniques.
Outline 1. General Design and Problem Solving Strategies 2. More about Dynamic Programming – Example: Edit Distance 3. Backtracking (if there is time)
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Dynamic Programming Carrie Williams. What is Dynamic Programming? Method of breaking the problem into smaller, simpler sub-problems Method of breaking.
CSE 780 Algorithms Advanced Algorithms Greedy algorithm Job-select problem Greedy vs DP.
1 Algorithm Design Techniques Greedy algorithms Divide and conquer Dynamic programming Randomized algorithms Backtracking.
Backtracking.
Dynamic Programming UNC Chapel Hill Z. Guo.
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
Recursion and Dynamic Programming. Recursive thinking… Recursion is a method where the solution to a problem depends on solutions to smaller instances.
Fundamentals of Algorithms MCS - 2 Lecture # 7
1 Summary: Design Methods for Algorithms Andreas Klappenecker.
Algorithm Paradigms High Level Approach To solving a Class of Problems.
CSC 413/513: Intro to Algorithms Greedy Algorithms.
CSC401: Analysis of Algorithms CSC401 – Analysis of Algorithms Chapter Dynamic Programming Objectives: Present the Dynamic Programming paradigm.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 17.
Honors Track: Competitive Programming & Problem Solving Optimization Problems Kevin Verbeek.
Topic 25 Dynamic Programming "Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it.
Greedy Algorithms. What is “Greedy Algorithm” Optimization problem usually goes through a sequence of steps A greedy algorithm makes the choice looks.
Dynamic Programming. Many problem can be solved by D&C – (in fact, D&C is a very powerful approach if you generalize it since MOST problems can be solved.
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.
Dynamic Programming.  Decomposes a problem into a series of sub- problems  Builds up correct solutions to larger and larger sub- problems  Examples.
1 Today’s Material Dynamic Programming – Chapter 15 –Introduction to Dynamic Programming –0-1 Knapsack Problem –Longest Common Subsequence –Chain Matrix.
Fundamental Data Structures and Algorithms Ananda Guna March 18, 2003 Dynamic Programming Part 1.
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
Greedy Algorithms Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Lecture 12.
Data Structures Lab Algorithm Animation.
Dynamic Programming Sequence of decisions. Problem state.
Design & Analysis of Algorithm Dynamic Programming
Lecture 5 Dynamic Programming
Weighted Interval Scheduling
Dynamic Programming Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Introduction to the Design and Analysis of Algorithms
Chapter 8 Dynamic Programming
Types of Algorithms.
Lecture 5 Dynamic Programming
Algorithm Design Methods
DYNAMIC PROGRAMMING.
Dynamic Programming.
Dynamic Programming.
Prepared by Chen & Po-Chuan 2016/03/29
Unit-5 Dynamic Programming
Types of Algorithms.
Greedy Algorithm Enyue (Annie) Lu.
Chapter 6 Dynamic Programming
Chapter 6 Dynamic Programming
Dynamic Programming Dr. Yingwu Zhu Chapter 15.
Analysis of Algorithms CS 477/677
DYNAMIC PROGRAMMING.
Types of Algorithms.
Lecture 4 Dynamic Programming
Total running time is O(E lg E).
Presentation transcript:

Problem Solving Dr. Andrew Wallace PhD BEng(hons) EurIng

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

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

Brute Force

Searching a list Travelling salesman problem Deoxyribonucleic acid Heuristics!

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

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

Greedy Algorithms Local optimum results in global optimum Problem: Shortest path from A to B Museum Safe House

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

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

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

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

Greedy Algorithms O(n)

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

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

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

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)

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

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

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

Dynamic programming O(n)

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

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

Divide and Conquer

Find

Divide and Conquer Find 90 Divide into two

Divide and Conquer Find 90 Divide into two And again!

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

Divide and Conquer

Problem solving Top down greedy Bottom up dynamic

Questions?