Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter 15.3, Problem 4E
Program Plan Intro
To describe the instance of the matrix-chain multiplication problem for which the greedy approach yields optimal solution.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
a. If an optimal solution can be created for a problem by constructing optimal solutions for its subproblems, the problem possesses __________ property.
Develop a dynamic programming algorithm for the knapsack problem: given n items of know weights w1, . . . , wn and values v1, . . . ,vn and a knapsack of capacity W, find the most valuable subset of the items that fit into the knapsack. We assume that all the weights and the knapsack’s capacity are positive integers, while the item values are positive real numbers. (This is the 0-1 knapsack problem).
Analyze the structure of an optimal solution.
Give the recursive solution.
Give a solution to this problem by writing pseudo code procedures.
Analyze the running time for your algorithms.
Solve the following exercise using jupyter notebook for Python, to find the objective function, variables, constraint matrix and print the graph with the optimal solution.
A farm specializes in the production of a special cattle feed, which is a mixture of corn and soybeans. The nutritional composition of these ingredients and their costs are as follows:
- Corn contains 0.09 g of protein and 0.02 g of fiber per gram, with a cost of.$0.30 per gram.- Soybeans contain 0.60 g of protein and 0.06 g of fiber per gram, at a cost of $0.90 per gram.0.90 per gram.
The dietary needs of the specialty food require a minimum of 30% protein and a maximum of 5% fiber. The farm wishes to determine the optimum ratios of corn and soybeans to produce a feed with minimal costs while maintaining nutritional constraints and ensuring that a minimum of 800 grams of feed is used daily.
Restrictions
1. The total amount of feed should be at least 800 grams per day.2. The feed should contain at least 30% protein…
Chapter 15 Solutions
Introduction to Algorithms
Ch. 15.1 - Prob. 1ECh. 15.1 - Prob. 2ECh. 15.1 - Prob. 3ECh. 15.1 - Prob. 4ECh. 15.1 - Prob. 5ECh. 15.2 - Prob. 1ECh. 15.2 - Prob. 2ECh. 15.2 - Prob. 3ECh. 15.2 - Prob. 4ECh. 15.2 - Prob. 5E
Ch. 15.2 - Prob. 6ECh. 15.3 - Prob. 1ECh. 15.3 - Prob. 2ECh. 15.3 - Prob. 3ECh. 15.3 - Prob. 4ECh. 15.3 - Prob. 5ECh. 15.3 - Prob. 6ECh. 15.4 - Prob. 1ECh. 15.4 - Prob. 2ECh. 15.4 - Prob. 3ECh. 15.4 - Prob. 4ECh. 15.4 - Prob. 5ECh. 15.4 - Prob. 6ECh. 15.5 - Prob. 1ECh. 15.5 - Prob. 2ECh. 15.5 - Prob. 3ECh. 15.5 - Prob. 4ECh. 15 - Prob. 1PCh. 15 - Prob. 2PCh. 15 - Prob. 3PCh. 15 - Prob. 4PCh. 15 - Prob. 5PCh. 15 - Prob. 6PCh. 15 - Prob. 7PCh. 15 - Prob. 8PCh. 15 - Prob. 9PCh. 15 - Prob. 10PCh. 15 - Prob. 11PCh. 15 - Prob. 12P
Knowledge Booster
Similar questions
- Please find an optimal parenthesization of a matrix chain product whose sequence of dimensions is <10, 5, 10, 4, 8>. Please show your works. Also, explain the computational complexity and real cost of calculating the matrix chain product.arrow_forwardIn this question you will explore the Traveling Salesperson Problem (TSP). (a) In every instance (i.e., example) of the TSP, we are given n cities, where each pair of cities is connected by a weighted edge that measures the cost of traveling between those two cities. Our goal is to find the optimal TSP tour, minimizing the total cost of a Hamiltonian cycle in G. Although it is NP-complete to solve the TSP, we found a simple 2-approximation by first generating a minimum-weight spanning tree of G and using this output to determine our TSP tour. Prove that our output is guaranteed to be a 2-approximation, provided the Triangle Inequality holds. In other words, if OP T is the total cost of the optimal solution, and AP P is the total cost of our approximate solution, clearly explain why AP P ≤ 2 × OP T.arrow_forwardB. If a Genetic Algorithm suffers from local solution problem, what do you suggest to achieve global optimal solution?arrow_forward
- Consider the following Job Scheduling problem. We have one machine and a setof n jobs {1, 2, . . . , n} to run on this machine, one at a time. Each job has a start time sifinish time fi and profit pi where 0 ≤ si < fi < ∞ and pi > 0. Two jobs i and j are compatible if the intervals [si, fi)and [sj , fj ) do not overlap. The goal is to find a set A of mutually compatible jobs with the maximumtotal profit, i.e.,P j∈A pj is maximized.Consider the following two greedy choices. For each one, determine whether it is a “safe” greedy choicefor this Job Scheduling problem. If your answer is yes, prove the “Greedy-choice property”. If your answeris no, please give a counterexample and show that the greedy choice will not lead to an optimal solution. a.Greedy choice 1: Always select a job with the earliest finish time that is compatible with allpreviously selected activities.b.Greedy choice 2: Always select a job with the highest profit per time unit (i.e., pi/(fi − si))that is…arrow_forwardwrite a C++ program to Given a matrix of dimension m*n where each cell in the matrix can have values 0, 1 or 2 whichhas the following meaning:0: Empty cell1: Cells have fresh oranges2: Cells have rotten orangesSo we have to determine what is the minimum time required so that all the oranges becomerotten. A rotten orange at index [i,j] can rot other fresh orange at indexes [i-1,j], [i+1,j], [i,j-1],[i,j+1] (up, down, left and right). If it is impossible to rot every orange then simply return -1.Examples:Input: arr[][C] = { {2, 1, 0, 2, 1},{1, 0, 1, 2, 1},{1, 0, 0, 2, 1}};Output:All oranges can become rotten in 2 time frames.Input: arr[][C] = { {2, 1, 0, 2, 1},Tahir Iqbal Department of Computer Sciences. BULC{0, 0, 1, 2, 1},{1, 0, 0, 2, 1}};Output:All oranges cannot be rotten.Below is algorithm.1) Create an empty Q.2) Find all rotten oranges and enqueue them to Q. Also enqueuea delimiter to indicate beginning of next time frame.3) While Q is not empty do following3.a) While delimiter in…arrow_forwardThis characteristic is met by a problem if it is feasible to develop an optimum solution for it by first creating optimal solutions for its subproblems. a) Subproblems that overlap; b) substructure that's optimum; c) memorization; d) greedyarrow_forward
- Answer the given question with a proper explanation and step-by-step solution and don't copy past from online source. Find an optimal parenthesization and the minimum number of scalar multiplications needed for a matrix-chain product whose sequence of dimensions is (5,10,3,12,5,50. Show all the steps used to arrive at the solution.arrow_forwardIf it is possible to create an optimal solution for a problem by constructing optimal solutions for its subproblems, then the problem possesses the corresponding property. a) Subproblems which overlap b) Optimal substructure c) Memorization d) Greedyarrow_forward6. Consider a modification to the rod-cutting problem in which, in addition to a value pi for each rod, there is handling cost ci that is one and a half times the length of the rod cut plus a flat fee of 3 (i.e., the handling cost to cut a rod of length 5 is 7.5+3 =10). The revenue generated is the sum of the value of the pieces cut minus the sum of handling costs of the cuts. Provide a dynamic programming approach to solve this problem given an initial rod of length n with potential cut lengths of 1, 2, 5, and 7 [Adapted from ITA, pg. 370, 15.1-3] length of cut (i) 1 2 5 7 value (pi) 5 7 30 45 handling cost (ci) 4.5 6 10.5 13.5arrow_forward
- Consider the set of vectors S = (9, 6, −1), (1, −7, 3), (−6, 9, 5), (3, 1, 5).(a) Create a linear program that would determine if the vector (4, 1, 2) can be ex-pressed as a convex combination of the vectors in the set S. (You will need a“dummy” objective function like min 0.)(b) Try to solve your model from part (a) using Matlab’s linprog function (or othersoftware). If the model is feasible, report your solution. If it is infeasible, reportthat fact.(c) Is (4, 1, 2) within the convex hull of S? Explain.arrow_forwardIn this problem we have n jobs j1, j2, ..., jn, each has an associated deadline d1, d2, ..., dn and profit p1, p2, ..., pn. Profit will only be awarded or earned if the job is completed before the deadline. We assume that each job takes 1 unit of time to complete. The objective is to earn maximum profit when only one job can be scheduled or processed at any given time.Provide the pseudocode of an algorithm to find the sequence of jobs to do with the maximum total profit. Also describe the main idea of your algorithm using plain language.[Hint: You can select the jobs in a greedy way. You can use the following example to help your analysis.] Job J1 J2 J3 J4 J5 Deadline 2 1 3 2 1 Profit 60 100 20 40 20 The best job sequence would be J2 →J1 →J3.arrow_forwardThe issue is said to have the given property if it is feasible to develop an optimum solution for the problem by first successfully creating optimal solutions for each of the problem's subproblems. a) Subproblems that overlap one another; b) achieving optimum substructure; c) memory; and d) being greedyarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole