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 35.4, Problem 4E
Program Plan Intro
To show that constraints present in line
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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.
Machine Learning Problem
Perform the optimization problem of finding the minimum of J(x) = (2x-3)2 by:
(i) defining theta, J(theta), h(theta) as defined in the Stanford Machine Learning videos in Coursera;
(ii) plotting J(theta) vs theta by hand then use a program
(iii) determining its minimum using gradient descent approach starting from a random initial value of theta = 5. Perform the search for the minimum using the gradient descent approach by hand calculations, i.e., step 1, step 2, etc. showing your work completely
How would you modify the dynamic programming algorithm for the coin collecting problem if some cells on the board are inaccessible for the robot? Apply your algorithm to the board below, where the inaccessible cells are shown by X’s. How many optimal paths are there for this board? You need to provide 1) a modified recurrence relation, 2) a pseudo code description of the algorithm, and 3) a table that stores solutions to the subproblems.
Chapter 35 Solutions
Introduction to Algorithms
Ch. 35.1 - Prob. 1ECh. 35.1 - Prob. 2ECh. 35.1 - Prob. 3ECh. 35.1 - Prob. 4ECh. 35.1 - Prob. 5ECh. 35.2 - Prob. 1ECh. 35.2 - Prob. 2ECh. 35.2 - Prob. 3ECh. 35.2 - Prob. 4ECh. 35.2 - Prob. 5E
Ch. 35.3 - Prob. 1ECh. 35.3 - Prob. 2ECh. 35.3 - Prob. 3ECh. 35.3 - Prob. 4ECh. 35.3 - Prob. 5ECh. 35.4 - Prob. 1ECh. 35.4 - Prob. 2ECh. 35.4 - Prob. 3ECh. 35.4 - Prob. 4ECh. 35.5 - Prob. 1ECh. 35.5 - Prob. 2ECh. 35.5 - Prob. 3ECh. 35.5 - Prob. 4ECh. 35.5 - Prob. 5ECh. 35 - Prob. 1PCh. 35 - Prob. 2PCh. 35 - Prob. 3PCh. 35 - Prob. 4PCh. 35 - Prob. 5PCh. 35 - Prob. 6PCh. 35 - Prob. 7P
Knowledge Booster
Similar questions
- 1. Let f(x₁, x₂) = x₁ cos(x₂) e¯*₁. What is the gradient Vf(x) of f?arrow_forwardThe image as attached is the question, and I have already had the answer with red text. Please write a python program for me to solve this question, thank you!arrow_forwardP is the set of problems that can be solved in polynomial time. More formally, P is the set of decision problems (e.g. given a graph G, does this graph G contain an odd cycle) for which there exists a polynomial-time algorithm to correctly output the answer to that problem. What is NP? Consider these five options. A. NP is the set of problems that cannot be solved in polynomial time. B. NP is the set of problems whose answer can be found in polynomial time. C. NP is the set of problems whose answer cannot be found in polynomial time. D. NP is the set of problems that can be verified in polynomial time. E. NP is the set of problems that cannot be verified in polynomial time. Determine which option is correct. Answer either A, B, C, D, or E.arrow_forward
- Consider the algorithm SeldeLP. Construct an example to show that the optimum of the linear program defined by the constraints in B(H\h) u {h} may be different from the optimum of the linear program defined by H. Thus, if the test in Step 2.1 fails and we proceed to Step 2.2, it does not suffice to consider the constraints in B(H\h) u {h} alone.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_forwardhe heuristic path algorithm is a best-first search in which the objective function is f(n) = (4 −w)g(n) + wh(n). For what values of w is this algorithm guaranteed to be optimal? What kind of search does this perform when w = 0? When w = 1? When w = 4?arrow_forward
- The monotone restriction (MR) on the heuristic function is defined as h (nj ) 2 h (ni ) - c (ni , nj ). Please prove the following: 1. If h(n)arrow_forwardUsing c++ Apply both breadth-first search and best-first search to a modified version of MC problem. In the modified MC, a state can contain any number of M’s and any number of C’s on either side of the river. Assume the goal is always to move all the persons on the left side to the right side. The Initial state should be a parameter given to the program at beginning of execution. As in the original problem, boat capacity =2, the boat cannot move by itself, and on either side C’s should not outnumber M’s. For best-first search, you need to come up with an appropriate heuristic. In addition to solving the problem, your grade will also be based on th effectiveness of the heuristic. As an example, the program should execute as follows. Initial state… Enter number of M’s on left side of the river: 3 Enter number of C’s on left side of the river: 1 Enter number of M’s on right side of the river: 0 Enter number of C’s on right side of the river: 0 Enter location of the boat: L The output…arrow_forwardProblem 3: A day at the beach. A group of n people are lying on the beach. The beach is represented by the real line R and the location of the i-th person is some integer r; e Z. Your task is to prevent people from getting sunburned by covering them with umbrellas. Each umbrella corresponds to a closed interval I = [a, a + L] of length L e N, and the i-th person is covered by that umbrella if æ¡ € I. Design a greedy algorithm for covering all people with the minimum number of umbrellas. The input consists of the integers x1,..., En, and L. The output of your algorithm should be the positions of umbrellas. For example, if the input is r1 = 1, x2 = 3, r3 = 5, and L = 2, then an optimum solution is the set of two umbrellas placed at positions 2 and 5, covering intervals [1,3] and [4,6]. 1 2 3 4 5 6 Prove that your algorithm is correct and that it runs in time polynomial in n.arrow_forwardExercise 4 20= 10+4+6 The rod-cutting problem consists of a rod of n units long that can be cut into integer-length pieces. The sale price of a piece i units long is Pi for i = 1,...,n. We want to apply dynamic programming to find the maximum total sale price of the rod. Let F(k) be the maximum price for a given rod of length k. 1. Give the recurrence on F(k) and its initial condition(s). 2. What are the time and space efficiencies of your algorithm? Now, consider the following instance of the rod-cutting problem: a rod of length n=5, and the following sale prices P1=2, P2=3, P3-7, P4=2 and P5=5.arrow_forwardn = 9. sign and Analysis of Algorithms (3rd ed.) [Levitin 2011-10-09].pdf ✓ 1 2 3 zoom O 4 O 5. How would you modify the dynamic programming algorithm for the coin- collecting problem if some cells on the board are inaccessible for the robot? Apply your algorithm to the board below, where the inaccessible cells are shown by X's. How many optimal paths are there for this board? 1 3 4 5 6 8.1 Three Basic Examples 2 X O 5 XXX 2 O Xo X O Search Fri May 12 291 6. Rod-cutting problem Design a dynamic programming algorithm for the fol- lowing problem. Find the maximum total sale price that can be obtained by cutting a rod of n units long into integer-length pieces if the sale price of a piece i units long is p; for i = 1, 2, ..., n. What are the time and space efficiencies of your algorithm? 7. Shortest-path counting A chess rook can move horizontally or vertically to any square in the same row or in the same column of a chessboard. Find the number of shortest paths by which a rook can move…arrow_forward8. A school is creating class schedules for its students. The students submit their requested courses and then a program will be designed to find the optimal schedule for all students. The school has determined that finding the absolute best schedule cannot be solved in a reasonablo time. Instead they have decided to use a simpler algorithm that produces a good but non-optimal schedule in a more reasonable amount of time. Which principle does this decision best demonstrate? O A Unreasonable algorithms may sometimes also be undecidable O B. Heuristics can be used to solve some problems for which no reasonable algorithm exsts O C. efficiency Two algorithms that solve the same problem must also have the same O B. Approximate solutions are often identical to optimal solutionsarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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