Exam 2 LZW not on syllabus. 73% / 75%.

Slides:



Advertisements
Similar presentations
Unit-iv.
Advertisements

Algorithm Design Methods (I) Fall 2003 CSE, POSTECH.
Algorithm Design Methods Spring 2007 CSE, POSTECH.
 Review: The Greedy Method
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
Greedy Algorithms.
Chapter 3: Planning and Scheduling Lesson Plan
Chapter 5 Fundamental Algorithm Design Techniques.
Greed is good. (Some of the time)
Chapter 4 The Greedy Approach. Minimum Spanning Tree A tree is an acyclic, connected, undirected graph. A spanning tree for a given graph G=, where E.
S. J. Shyu Chap. 1 Introduction 1 The Design and Analysis of Algorithms Chapter 1 Introduction S. J. Shyu.
Lecture 7: Greedy Algorithms II Shang-Hua Teng. Greedy algorithms A greedy algorithm always makes the choice that looks best at the moment –My everyday.
Dealing with NP-Complete Problems
Week 2: Greedy Algorithms
Lecture 7: Greedy Algorithms II
IT 60101: Lecture #201 Foundation of Computing Systems Lecture 20 Classic Optimization Problems.
Introduction to Job Shop Scheduling Problem Qianjun Xu Oct. 30, 2001.
For Wednesday No reading No homework There will be homework for Friday, as well the program being due – plan ahead.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Greedy Algorithms. What is “Greedy Algorithm” Optimization problem usually goes through a sequence of steps A greedy algorithm makes the choice looks.
December 14, 2015 Design and Analysis of Computer Algorithm Pradondet Nilagupta Department of Computer Engineering.
Algorithm Design Methods 황승원 Fall 2011 CSE, POSTECH.
© The McGraw-Hill Companies, Inc., Chapter 1 Introduction.
CS 361 – Chapter 10 “Greedy algorithms” It’s a strategy of solving some problems –Need to make a series of choices –Each choice is made to maximize current.
1 Ch18. The Greedy Methods. 2 BIRD’S-EYE VIEW Enter the world of algorithm-design methods In the remainder of this book, we study the methods for the.
Chapter 6 Branch & Bound (B & B).
The Theory of NP-Completeness
Hard Problems Some problems are hard to solve.
Dynamic Programming Sequence of decisions. Problem state.
Lecture on Design and Analysis of Computer Algorithm
Greedy Method 6/22/2018 6:57 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Algorithm Design Methods
Merge Sort 7/29/ :21 PM The Greedy Method The Greedy Method.
Design & Analysis of Algorithm Greedy Algorithm
Design and Analysis of Algorithm
Approximation Algorithms
Greedy Algorithms / Interval Scheduling Yin Tat Lee
Algorithm Design Methods
Heuristics Definition – a heuristic is an inexact algorithm that is based on intuitive and plausible arguments which are “likely” to lead to reasonable.
Unit 3 (Part-I): Greedy Algorithms
Merge Sort 11/28/2018 2:18 AM The Greedy Method The Greedy Method.
Merge Sort 11/28/2018 8:16 AM The Greedy Method The Greedy Method.
CS4335 Design and Analysis of Algorithms/WANG Lusheng
Greedy Algorithm Enyue (Annie) Lu.
Richard Anderson Lecture 28 Coping with NP-Completeness
MCA 301: Design and Analysis of Algorithms
Lecture 11 Overview Self-Reducibility.
Advanced Algorithms Analysis and Design
Merge Sort 1/17/2019 3:11 AM The Greedy Method The Greedy Method.
Lecture 6 Topics Greedy Algorithm
Richard Anderson Lecture 6 Greedy Algorithms
Richard Anderson Autumn 2016 Lecture 7
Branch and Bound Searching Strategies
Richard Anderson Lecture 7 Greedy Algorithms
Algorithm Design Methods
Topic 15 Job Shop Scheduling.
Lecture 6 Greedy Algorithms
Algorithm Design Methods
The Theory of NP-Completeness
Richard Anderson Winter 2019 Lecture 7
Dynamic Programming Sequence of decisions. Problem state.
Merge Sort 5/2/2019 7:53 PM The Greedy Method The Greedy Method.
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Chapter 3: Planning and Scheduling Lesson Plan
Advance Algorithm Dynamic Programming
Chapter 1. Formulations.
Approximation Algorithm
Dynamic Programming Sequence of decisions. Problem state.
Department of Computer Science & Engineering
Algorithm Design Methods
Presentation transcript:

Exam 2 LZW not on syllabus. 73% / 75%

maxLevel (40%)

removeMin (74%) 20 10 40 6 15 30 18 25 35 2 8 7

Remedy Lower the cutoffs. Another test. Best of two scores. Options Next Tu or Th. Make up exam tonight, CSE 404.

Algorithm Design Methods Greedy method. Divide and conquer. Dynamic Programming. Backtracking. Branch and bound.

Some Methods Not Covered Linear Programming. Integer Programming. Simulated Annealing. Neural Networks. Genetic Algorithms. Tabu Search.

Optimization Problem A problem in which some function (called the optimization or objective function) is to be optimized (usually minimized or maximized) subject to some constraints.

Machine Scheduling Find a schedule that minimizes the finish time. optimization function … finish time constraints each job is scheduled continuously on a single machine for an amount of time equal to its processing requirement no machine processes more than one job at a time

Bin Packing Pack items into bins using the fewest number of bins. optimization function … number of bins constraints each item is packed into a single bin the capacity of no bin is exceeded

Min Cost Spanning Tree Find a spanning tree that has minimum cost. optimization function … sum of edge costs constraints must select n-1edges of the given n vertex graph the selected edges must form a tree

Feasible And Optimal Solutions A feasible solution is a solution that satisfies the constraints. An optimal solution is a feasible solution that optimizes the objective/optimization function.

Greedy Method Solve problem by making a sequence of decisions. Decisions are made one by one in some order. Each decision is made using a greedy criterion. A decision, once made, is (usually) not changed later.

Container Loading Ship has capacity c. m containers are available for loading. Weight of container i is wi. Each weight is a positive number. Sum of container weights > c. Load as many containers as is possible without sinking the ship. Similar to truck loading.

Greedy Solution Load containers in increasing order of weight until we get to a container that doesn’t fit. Does this greedy algorithm always load the maximum number of containers? Yes. May be proved using a proof by induction (see text).

Container Loading With 2 Ships Can all containers be loaded into 2 ships whose capacity is c (each)? Same as bin packing with 2 bins. Are 2 bins sufficient for all items? Same as machine scheduling with 2 machines. Can all jobs be completed by 2 machines in c time units? NP-hard.

0/1 Knapsack Problem

0/1 Knapsack Problem Hiker wishes to take n items on a trip. The weight of item i is wi. The items are to be carried in a knapsack whose weight capacity is c. When sum of item weights <= c, all n items can be carried in the knapsack. When sum of item weights > c, some items must be left behind. Which items should be taken/left?

0/1 Knapsack Problem Hiker assigns a profit/value pi to item i. All weights and profits are positive numbers. Hiker wants to select a subset of the n items to take. The weight of the subset should not exceed the capacity of the knapsack. (constraint) Cannot select a fraction of an item. (constraint) The profit/value of the subset is the sum of the profits of the selected items. (optimization function) The profit/value of the selected subset should be maximum. (optimization criterion)

0/1 Knapsack Problem Let xi = 1 when item i is selected and let xi = 0 when item i is not selected. i = 1 n pi xi maximize i = 1 n wi xi <= c subject to Same as ship loading to maximize earnings. Each container has a weight and profit. and xi = 0 or 1 for all i

Greedy Attempt 3 Be greedy on profit density (p/w). n = 2, c = 7 Select items in decreasing order of profit density. n = 2, c = 7 w = [1, 7] p = [10, 20] only item 1 is selected profit (value) of selection is 10 not best selection!

Greedy Attempt 3 Be greedy on profit density (p/w). n = 2, c = 7 Works when selecting a fraction of an item is permitted Select items in decreasing order of profit density, if next item doesn’t fit take a fraction so as to fill knapsack. n = 2, c = 7 w = [1, 7] p = [10, 20] item 1 and 6/7 of item 2 are selected

0/1 Knapsack Greedy Heuristics Select a subset with <= k items. If the weight of this subset is > c, discard the subset. If the subset weight is <= c, fill as much of the remaining capacity as possible by being greedy on profit density. Try all subsets with <= k items and select the one that yields maximum profit.

0/1 Knapsack Greedy Heuristics (best value - greedy value)/(best value) <= 1/(k+1) Number of solutions (out of 600) within x% of best.

0/1 Knapsack Greedy Heuristics First sort into decreasing order of profit density. There are O(nk) subsets with at most k items. Trying a subset takes O(n) time. Total time is O(nk+1) when k > 0. (best value - greedy value)/(best value) <= 1/(k+1)