Problem solving sequence

Slides:



Advertisements
Similar presentations
Introduction to Algorithms Greedy Algorithms
Advertisements

The Greedy Method1. 2 Outline and Reading The Greedy Method Technique (§5.1) Fractional Knapsack Problem (§5.1.1) Task Scheduling (§5.1.2) Minimum Spanning.
Types of Algorithms.
1.1 Data Structure and Algorithm Lecture 6 Greedy Algorithm Topics Reference: Introduction to Algorithm by Cormen Chapter 17: Greedy Algorithm.
Chapter 5 Fundamental Algorithm Design Techniques.
Greedy Algorithms Clayton Andrews 2/26/08. What is an algorithm? “An algorithm is any well-defined computational procedure that takes some value, or set.
Cs333/cutler Greedy1 Introduction to Greedy Algorithms The greedy technique Problems explored –The coin changing problem –Activity selection.
CSE115/ENGR160 Discrete Mathematics 02/28/12
Merge Sort 4/15/2017 6:09 PM The Greedy Method The Greedy Method.
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
1 The Greedy Method CSC401 – Analysis of Algorithms Lecture Notes 10 The Greedy Method Objectives Introduce the Greedy Method Use the greedy method to.
10/31/02CSE Greedy Algorithms CSE Algorithms Greedy Algorithms.
10/31/02CSE Greedy Algorithms CSE Algorithms Greedy Algorithms.
Lecture 23. Greedy Algorithms
Dr. Naveed Ahmad Assistant Professor Department of Computer Science University of Peshawar.
Nikki Keesee.  We will be learning how to count coins  Quarters  Dimes  Nickels  Pennies  Use a decimal point for coins (.)  Use a dollar sign.
Counting Coins. The Basics Quarter 25 cents Dime 10 cents.
The Fundamentals: Algorithms, the Integers & Matrices.
5-1-1 CSC401 – Analysis of Algorithms Chapter 5--1 The Greedy Method Objectives Introduce the Brute Force method and the Greedy Method Compare the solutions.
Let’s Learn About Money!
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Section 3.1. Section Summary Properties of Algorithms Algorithms for Searching and Sorting Greedy Algorithms Halting Problem.
Name the United States Coins Count the Pennies 10 ¢
MATH AND MONEY.
The Greedy Method. The Greedy Method Technique The greedy method is a general algorithm design paradigm, built on the following elements: configurations:
CS 103 Discrete Structures Lecture 12
Greedy Algorithms Seize the moment. Elements and Concerns Often an optimization problem Feasible solutions can be built in steps Quality of the next step.
Spring 2008The Greedy Method1. Spring 2008The Greedy Method2 Outline and Reading The Greedy Method Technique (§5.1) Fractional Knapsack Problem (§5.1.1)
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
Money, Money, Money, Money!!!!!!! Counting money is as easy as 1, 2, 3.
2 nd Grade Math Counting Money by Annette Burchett.
Greedy Algorithms Prof. Kharat P. V. Department of Information Technology.
What is your strategy for counting money?
CSE15 Discrete Mathematics 03/06/17
Greedy Algorithms.
Greedy Technique.
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.
Department of Computer Science
Merge Sort 7/29/ :21 PM The Greedy Method The Greedy Method.
The Greedy Method and Text Compression
Spanning Trees Lecture 21 CS2110 – Fall 2016.
CS 2210 Discrete Structures Algorithms and Complexity
CS330 Discussion 4 Spring 2017.
Greedy Algorithms.
CSCE350 Algorithms and Data Structure
Money, Money, Money.
CS 3343: Analysis of Algorithms
Types of Algorithms.
Merge Sort 11/28/2018 2:18 AM The Greedy Method The Greedy Method.
The Greedy Method Spring 2007 The Greedy Method Merge Sort
Merge Sort 11/28/2018 2:21 AM The Greedy Method The Greedy Method.
Merge Sort 11/28/2018 8:16 AM The Greedy Method The Greedy Method.
Greedy Algorithm Enyue (Annie) Lu.
Advanced Analysis of Algorithms
Name the United States Coins
Discrete Mathematics CMP-101 Lecture 12 Sorting, Bubble Sort, Insertion Sort, Greedy Algorithms Abdul Hameed
Greedy Algorithms.
Merge Sort 1/17/2019 3:11 AM The Greedy Method The Greedy Method.
Graph Searching.
Lecture 6 Topics Greedy Algorithm
Algorithms CSCI 235, Spring 2019 Lecture 29 Greedy Algorithms
CSCE 222 Discrete Structures for Computing
Types of Algorithms.
Algorithm Design Techniques Greedy Approach vs Dynamic Programming
CSC 380: Design and Analysis of Algorithms
Merge Sort 5/2/2019 7:53 PM The Greedy Method The Greedy Method.
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Greedy algorithms.
Money Week 31 April 3 , 2019.
Presentation transcript:

Problem solving sequence A teacher assigns homework problems(from the basket of problems which vary for each student) to each student at the beginning of the first day of class. Each homework problem carries one mark, plus a bonus if submitted within a specified number of days. The deadline for earning the bonus and the number of bonus marks are different for each homework problem. For instance, if a problem has a deadline of 6 days and carries 10 marks as bonus, then it earns 10 bonus marks provided it is submitted before the end of the 6th day. Each homework problem takes exactly one day to complete. Develop a program to suggest the solving sequence to the students to earn maximum marks. (Hint : Assume that the class called ‘problem’ that contains the members ‘problem number’,‘deadline’ and ‘bonus mark’. Derive a new class called ‘students’ derived from class ‘problem’ with members ‘roll number of the students’, ‘name of the students’ and ‘list of problems assigned’)

More about the previous example…. For instance, suppose there are seven problems with deadlines and bonuses as follows: Problem number 1 2 3 4 5 6 7 Deadline for bonus 1 1 3 3 2 2 6 Bonus marks 6 7 2 1 4 5 1 The maximum number of bonus marks one can obtain is 15, which can be achieved by completing the problems in the sequence 2,6,3,7 Note that there are also other sequences that achieve the same effect.

UML diagram Class Problem represents a set of problems given to the students in an assignment, it is assumed that there will be maximum of ten problems and no'of problems(nop) is given as input for get and put Student assignment is a set of problems plus name and rollno of student for whom it is given

The method: Applicable to optimization problems ONLY Constructs a solution through a sequence of steps Each step expands a partially constructed solution so far, until a complete solution to the problem is reached. On each step, the choice made must be Feasible: it has to satisfy the problem’s constraints( without regard for future consequences) Locally optimal: it has to be the best local choice among all feasible choices available on that step Irrevocable: Once made, it cannot be changed on subsequent steps of the algorithm

Greedy techniques The greedy method is a general algorithm design paradigm, built on the following elements: configurations: different choices, collections, or values to find objective function: a score assigned to configurations, which we want to either maximize or minimize

Example Consider the problem of "Making Change". Coins available are: dollars (100 cents) quarters (25 cents) dimes (10 cents) nickels (5 cents) pennies (1 cent)   Make a change of a given amount using the smallest possible number of coins.

Procedure to solve the ‘Making change” problem Start with nothing. at every stage without passing the given amount add the largest to the coins already chosen. Example :   Make a change for 2.89 (289 cents) here n = 2.89 and the solution contains 2 dollars, 3 quarters, 1 dime and 4 pennies. The algorithm is greedy because at every stage it chooses the largest coin without worrying about the consequences. Moreover, it never changes its mind in the sense that once a coin has been included in the solution set, it remains there. For US money, the greedy algorithm always gives the optimum solution

A failure of the greedy algorithm In some (fictional) monetary system, “krons” come in 1 kron, 7 kron, and 10 kron coins Using a greedy algorithm to count out 15 krons, you would get A 10 kron piece Five 1 kron pieces, for a total of 15 krons This requires six coins A better solution would be to use two 7 kron pieces and one 1 kron piece This only requires three coins The greedy algorithm results in a solution, but not in an optimal solution 8

Problem scheduling algorithm using greedy technique 1. Sort all problems in decreasing order of bonus mark 2. Initialize the result sequence as first problem in sorted problems. Do following for remaining n-1 problems ....... a)If the current problem can fit in the current result sequence without missing the deadline, add current problem to the result. Else ignore the current problem.