1 / 9

Problem solving sequence

Problem solving sequence.

takisha
Download Presentation

Problem solving sequence

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Problem solving sequence (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’) 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.

  2. 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 7Deadline for bonus 1 1 3 3 2 2 6Bonus marks 6 7 2 1 4 5 1The 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.

  3. 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

  4. 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

  5. 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

  6. 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.

  7. 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

  8. 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 A failure of the greedy algorithm 8

  9. 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.

More Related