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
Concept explainers
Question
Chapter 15.1, Problem 2E
Program Plan Intro
To give a counter example so that the following greedy strategy does not always determine an optimal way to cut rods.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
For the problem below, two ”high level” greedy strategy is given. One of the strategies givesa correct solutions, and the other sometimes gives an incorrect solutions. Decide which greedy strategyproduces optimal solutions, and give a proof that it is correct and a counter-example showing the otherstrategy is incorrect.( show proof and counter example)
You are given a list of classes C and a list of classrooms R. Each class c has a positive enrollment E(c)and each room r has a positive integer size S(r) which denotes its capacity. You want to assign eachclass a room in a way that minimizes the total sizes of rooms used. However, the capacity of the roomassigned to a class must be at least the enrollment of the class. You cannot assign two classes to thesame room.
Greedy strategy A: Repeat until all classes are assigned, or a class cannot be included in any unassignedroom. Assign the largest unassigned class to the smallest unassigned room larger than or equal to itsenrollment.
Greedy…
In the sequence alignment problem, suppose you knew that the input strings were relatively similar, in the sense that there is an optimal alignment that uses at most k gaps, where k is much smaller than the lengths m and n of the strings. Show how to compute the NW score in O((m+n)k) time.
Establish the Shortest-Paths Optimality Conditions in the Proposition P. Then, for any v reachable from s, the value of distTo[v] is the length of some path from s to v, with distTo[v] equal to infinity for all v not reachable from s. Let G be an edge-weighted digraph. s is a source vertex in G. distTo[] is a vertex-indexed array of path lengths in G. These numbers represent the lengths of the shortest pathways if and only if each edge e from v to w satisfies the condition that distTo[w] = distTo[v] + e.weight() (i.e., no edge is eligible).
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
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Suppose we have a heuristic h that over-estimates h* by at most epsilon (i.e., for all n, 0<= h(n) <= h*(n)+epsilon). Show that A* search using h will get a goal whose cost is guaranteed to be at most epsilon more than that of the optimal goal.arrow_forwardWhat is the solution by greedy algorithm to the change-making problem with denominations 1, 3, and 4 to return the minimum number of coins for an amount of 6? Copy and paste the following expression and replace the ? mark by a number ?(4), ?(3), ?(1) (Keep the same format) Is the solution provided by greedy algorithm to the change-making problem with denominations 1, 3, and 4 to return the minimum number of coins for an amount of 6 optimal or not? prove your answerarrow_forwardPlease answer the following question in full detail. Please be specifix about everything: You have learned before that A∗ using graph search is optimal if h(n) is consistent. Does this optimality still hold if h(n) is admissible but inconsistent? Using the graph in Figure 1, let us now show that A∗ using graph search returns the non-optimal solution path (S,B,G) from start node S to goal node G with an admissible but inconsistent h(n). We assume that h(G) = 0. Give nonnegative integer values for h(A) and h(B) such that A∗ using graph search returns the non-optimal solution path (S,B,G) from S to G with an admissible but inconsistent h(n), and tie-breaking is not needed in A∗.arrow_forward
- True or False: - Best-first search is optimal in the case where we have a perfect heuristic (i.e., h(?) = h∗(?), the true cost to the closest goal state). - Suppose there is a unique optimal solution. Then, A* search with a perfect heuristic will never expand nodes that are not in the path of the optimal solution.- A* search with a heuristic which is admissible but not consistent is complete.arrow_forwardA. One greedy strategy to solve the knapsack problem is to consider the items in order of decreasing values of where Vi and Si are the value and the size of item i. For each item, add it to the knapsack if it fits otherwise ignore it and move to the next item in the ordered list. Write a complete pseudocode for this strategy. The pseudocode should print the details of the solution (selected items, their total value and size). B. Show that this strategy does not necessarily yield optimal solutions. Take the example of exercise 1 and change the knapsack capacity to 15 (The value of the optimal solution is 54)..arrow_forwardUsing the image provided, please answer the following questions. (a). Find a path from a to g in the graph G using the search strategy of depth-first search. Is the returned solution path an optimal one? Give your explanation and remarks on "why-optimal" or "why-non-optimal". (b). Find a path from a to g in the graph G using the search strategy of breadth-first search. Is the returned solution path an optimal one? Give your explanation and remarks on "why-optimal" or "why-non-optimal".(c). Find a path from a to g in the graph G using the search strategy of least-cost first search. Is the returned solution path an optimal one? Give your explanation and remarks on "why-optimal" or "why-non-optimal". (d). Find a path from a to g in the graph G using the search strategy of best-first search. The heuristics for these nodes are: h(a,25); h(b, 43); h(c,5); h(d, 64); h(g, 0). Is the returned solution path an optimal one? Give your explanation and remarks on "why-optimal or "why-non-optimal".…arrow_forward
- The heuristic path algorithm is a best-first search in which the objective function is f(n)= 3w*g(n) + (2w+1) * h(n), 0≤w<3. For what values of w is this algorithm guaranteed to be optimal?arrow_forwardUse the bottom-up dynamic programming to determine an optimal set of coins. The greedy algorithm approach for this has an issue such as if we have the set of coins {1, 5, 6, 9} and we wanted to get the value 11. The greedy algorithm would give us {9,1,1} however the most optimal solution would be {5, 6} Write a bottom up approach that would show the set of coins {5,6} when we give the set of coins {1, 5, 6, 9} and a value of 11. P.S.: - I do not need the minimum number of coins, but want the set of coins to be shown. C++ or Python code is appreciatedarrow_forwardSuppose you are a cable guy and are sent out for jobs ji where each has a start time si and finish time fi. you can instantly start a new job once one is finished, but no jobs can overlap. your goal is to get as many jobs as you can done in one day.Prove that greedy strategy choosing the job that starts the latest is possible in an optimal solution. Prove suboptimality property holds for the cable guy problem.arrow_forward
- The gradient descent algorithm may get stuck in a local optimal point because the gradient is near zero at these points and the parameters don't get updated. Group of answer choices True Falsearrow_forwardConsider the problem of providing change for an amount of n-bahts while using the smallest possible quantity of coins. You may assume that each coin’s value is integer. Describe a greedy algorithm to make change consisting of 1-baht coins, 5-baht coins, and 10-baht coins and prove that your algorithm yields an optimal solution.arrow_forwarda. Given n items, where each item has a weight and a value, and a knapsack that can carry at most W You are expected to fill in the knapsack with a subset of items in order to maximize the total value without exceeding the weight limit. For instance, if n = 6 and items = {(A, 10, 40), (B, 50, 30), (C, 40, 80), (D, 20, 60), (E, 40, 10), (F, 10, 60)} where each entry is represented as (itemIdi, weighti, valuei). Use greedy algorithm to solve the fractional knapsack problem. b. Given an array of n numbers, write a java or python program to find the k largest numbers using a comparison-based algorithm. We are not interested in the relative order of the k numbers and assuming that (i) k is a small constant (e.g., k = 5) independent of n, and (ii) k is a constant fraction of n (e.g., k = n/4). Provide the Big-Oh characterization of your algorithm.arrow_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