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 16.1, Problem 1E
Program Plan Intro
To give a dynamic-
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Extend Lamport's Algorithm for k-mutual exclusion problem, which allows at most k processes enter the critical section at the same time.
The final code for finding the shortest weighted path across a directed level graph and solving the event scheduling problem are almost similar.algorithm Schedule (E, d) (E, d) pre-cond: A set of events E = ej with start time sj, end time fj, worth wj, and distances dj, j between them make up an instance. Optimal valid schedule of events optSol has event en as its conclusion.
Please don't use handwritting for this question
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 16 Solutions
Introduction to Algorithms
Ch. 16.1 - Prob. 1ECh. 16.1 - Prob. 2ECh. 16.1 - Prob. 3ECh. 16.1 - Prob. 4ECh. 16.1 - Prob. 5ECh. 16.2 - Prob. 1ECh. 16.2 - Prob. 2ECh. 16.2 - Prob. 3ECh. 16.2 - Prob. 4ECh. 16.2 - Prob. 5E
Ch. 16.2 - Prob. 6ECh. 16.2 - Prob. 7ECh. 16.3 - Prob. 1ECh. 16.3 - Prob. 2ECh. 16.3 - Prob. 3ECh. 16.3 - Prob. 4ECh. 16.3 - Prob. 5ECh. 16.3 - Prob. 6ECh. 16.3 - Prob. 7ECh. 16.3 - Prob. 8ECh. 16.3 - Prob. 9ECh. 16.4 - Prob. 1ECh. 16.4 - Prob. 2ECh. 16.4 - Prob. 3ECh. 16.4 - Prob. 4ECh. 16.4 - Prob. 5ECh. 16.5 - Prob. 1ECh. 16.5 - Prob. 2ECh. 16 - Prob. 1PCh. 16 - Prob. 2PCh. 16 - Prob. 3PCh. 16 - Prob. 4PCh. 16 - Prob. 5P
Knowledge Booster
Similar questions
- Using 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_forwardAssuming that the graph G = (V, E) is represented in Adjacency List format, justify in detail the fact Greedy independent sets can be implemented in O(n 2 + m) worst-case running time, where n = |V |, m = |E|. This will require you to take real care in how the adjustment of Adj is done in line 10. The key is to only update/delete what is really necessary for the Algorithm, rather than being concerned with an accurate representation of the residual graph.arrow_forwardSuppose we want to use UCS and the A* algorithm on the graph below to find the shortest path from node S to node G. Each node is labeled by a capital letter and the value of a heuristic function. Each edge is labeled by the cost to traverse that edge. Perform A*, UCS, and BFS on this graph. Indicate the f, g, and h values of each node for the A*. e.g., S = 0 + 6 = 6 (i.e. S = g(S) + h(S) = f(S)). Additionally, show how the priority queue changes with time. Show the order in which the nodes are visited for BFS and UCS. Show the path found by the A*, UCS, and BFS algorithms on the graph above. Make this example inadmissible by changing the heuristic value at one of the nodes. What node do you choose and what heuristic value do you assign? What would be the A* algorithm solution then.arrow_forward
- Let G = (X ∪ Y, E) be a bipartite graph such that the vertices are partitioned into two groups Xand Y , and each edge has one end point in X and one end point in Y .A 2-1 generalized matching is a set of edges S ⊂ E satisfying the following two conditions:1. Every vertex in X belongs to at most two edges in S.2. Every vertex in Y belongs to at most one edge in S.Give an algorithm to find the size (number of edges) of maximum 2-1 generalized matchingarrow_forwardAn unweighted graph G = (V, E) does not have weights associated with its edges asnoted. A simple strategy to find the maximal matching in a greedy way is to randomlyselect an edge in the graph, include it in the matching and remove all of its adjacentedges from the graph as in the steps below.1. Input: An unweighted graph G = (V, E)2. Output: A maximal matching M of G3. M ← Ø4. E ← E5. while E = Ø6. randomly select e ∈ E7. M ← M ∪ {e}8. E ← E \ {e∪ all adjacent edges to e}implement this algorithm in Pythonarrow_forwardImplement the algorithm for an optimal parenthesization of a matrix chain product as dis-cussed in the class.Use the following recursive function as part of your program to print the outcome, assumethe matrixes are namedA1, A2, ..., An.PRINT-OPTIMAL-PARENS(s, i, j){if (i=j) thenprint “A”i else{print “(”PRINT-OPTIMAL-PARENS(s,i,s[i, j])PRINT-OPTIMAL-PARENS(s, s[i, j] + 1, j)print “)”} }a- Test your algorithm for the following cases:1. Find and print an optimal parenthesization of a matrix-chain product whose sequenceof dimensions is<5,10,3, X,12,5,50, Y,6>.2. Find and print an optimal parenthesization of a matrix-chain product whose sequenceof dimensions is<5,10,50,6, X,15,40,18, Y,30,15, Z,3,12,5>. 3. Find and print an optimal parenthesization of a matrix-chain product whose sequenceof dimensions is<50,6, X,15,40,18, Y,5,10,3,12,5, Z,40,10,30,5>. X=10 Y=20 Z=30arrow_forward
- implement program to Finding the Longest Common Substringproblem that lends itself to a dynamic programming solution is finding the longest common substring in two strings. For example, in the words “raven” and “havoc”, the longest common substring is “av”.arrow_forwardWrite a recurrence that would be used in dynamic programming for thefollowing problem: Given a rod of length n and an array A of prices thatcontain all prices of all the pieces smaller than n. Determine the maximumvalue obtained by cutting up the rod and selling the pieces. Note that youcould sell the rod at its original length without cutting it.arrow_forwardYour task in this problem is to write a program in the Julia programming language that performs the following:• capture and store a Markov decision process (MDP) at runtime;• given a policy, evaluate the policy, and improve it to get a solution.arrow_forward
- Implement The dynamic programming algorithm for the leveled graph problem. pre-cond: G is a weighted directed layered graph, and s and t are nodes. post-cond: optSol is a path with minimum total weight from s tot, and optCost is its weight, and optNum is the number of possible optimal solutions.arrow_forwardSuppose we have the following undirected graph, and we know that the two bolded edges (B-E and G-E) constitute the global minimum cut of the graph. 1. If we run the Karger’s algorithm for just one time to find the global minimum cut, what is the probability for the algorithm to find the minimum cut correctly? Please show your reasoning process. 2. How many times do we need to run the Karger’s algorithm if we want to guarantee that the probability of success is greater than or equal to 0.95, by “success” we mean that there is at least one time the Karger’s algorithm correctly found the minimum cut. Please show your reasoning process. [You do not have to work out the exact value of a logarithm]arrow_forwardThe Triangle Vertex Deletion problem is defined as follows: Given: an undirected graph G = (V, E) , with IVI=n, and an integer k>= 0. Is there a set of at most k vertices in G whose deletion results in deleting all triangles in G? (a) Give a simple recursive backtracking algorithm that runs in O(3^k * ( p(n))) where p(n) is a low-degree polynomial corresponding to the time needed to determine whether a certain vertex belongs to a triangle in G. (b) Selecting a vertex that belong to two different triangles can result in a better algorithm. Using this idea, provide an improved algorithm whose running time is O((2.562^n) * p(n)) where 2.652 is the positive root of the equation x^2=x+4arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education