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
The matrix [A] has a norm of ||A||=3.2 x 10° and the norm of the inverse of that matrix is ||A-4||=2.5 x 1012 If a solution is obtained for a
system of equations [A]{x}={b} using this same matrix [A] and double precision computations, then
O the solution is very sensitive to input error
O the solution is insensitive to input error
O small residuals indicate accurate answers
O small residuals do not indicate accurate answers
O the system is ill-conditioned
USING PYTHON
A tridiagonal matrix is one where the only nonzero elements are the ones on the main diagonal (i.e., ai,j where j = i) and the ones immediately above and belowit(i.e.,ai,j wherej=i+1orj=i−1).
Write a function that solves a linear system whose coefficient matrix is tridiag- onal. In this case, Gauss elimination can be made much more efficient because most elements are already zero and don’t need to be modified or added.
Please show steps and explain.
We have N jobs and N workers to do these jobs. It is known and known (as a positive numerical value) at what cost each worker will do each job. We want to assign jobs to workers in such a way that the total cost of completion of all jobs is minimal among other possible alternative assignments. For this problem, the input is a matrix representing worker / job costs, and the output is a list of tuples showing which work will be done by which worker, andWrite the algorithm trying to reach the solution with OBUR / HURRY (GREEDY) technique as pseudocode. What does your algorithm mean?exhibits voracious / hasty behavior, please explain. What is the time complexity of your algorithm? Interpret if your algorithm always produces the best (optimum) result for each instance of the problem.
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
- Knapsack 0/1 problem: Given N items where each item has some weight and profit associated with it and also given a bag with capacity W, [i.e., the bag can hold at most W weight in it]. The task is to put the items into the bag such that the sum of profits associated with them is the maximum possible. Given the problem is solved using a dynamic programming approach and the matrix derived is given below, answer the below set of questions by analyzing the DP matrix. weights = [2, 3, 4, 5], profits = [1, 2, 5, 6], Capacity W = 8 Capacity 2 3 Profits weights|0 1 2 5 16 14 |-> 5 10 0 O 10 1 2 3 4 0 O 0 1 1 0 1 0 1 O 10 1 2 2 2 5 2 O 15 50 1 356 6 O 1 3 6 18 00378 7 10 10 1 3 7 7 1 18arrow_forwardComputer Science 3 Given a set of vectors contained in a matrix [1 2 3 4 21 2 3 M = 3 2 1 2 [4 3 2 1 Use the following inner product [2 0 0 07 0 100 001 0y 0 0 0 3 (1, y) = r" to compute an orthonormal set from columns of M using Gram-Schmidt process. The solution should be a matrix whose columns are orthonormal vectors. Bonus (project related): Solve this problem by writing a function to compute the inner product. MATLAB CODEarrow_forwardPls Use Python If there is a non-singular matrix P such as P-1AP=D , matrix A is called a diagonalizable matrix. A, n x n square matrix is diagonalizable if and only if matrix A has n linearly independent eigenvectors. In this case, the diagonal elements of the diagonal matrix D are the eigenvalues of the matrix A. A=({{1, -1, -1}, {1, 3, 1}, {-3, 1, -1}}) : 1 -1 -1 1 3 1 -3 1 -1 a)Write a program that calculates the eigenvalues and eigenvectors of matrix A using NumPy. b)Write the program that determines whether the D matrix is diagonal by calculating the D matrix, using NumPy. Ps: Please also explain step by step with " # "arrow_forward
- Let A be a n x m matrix of 0's and 1's. Design a dynamic programming O(nm) time algorithm for finding the largest square block of A that contains 1's only. Hint: Define the dynamic programming table (i, j) be the length of the side of the largest square block of 1's whose bottom right corner is A[i, j].arrow_forwardIn a company, there are several branches. Let us consider a branch of that company having N employees, if the manager is allotted to that branch(s) then he is known to everyone else in that branch. Note that the property of "known to everyone" is unique to a manager. Your task is to find the manager in that branch. Input from the user in main (), the square matrix M where if an element of row i and column j is set to 1 it means that ith person knows jth person. You need to write a function managerId () which returns the id of the manager if present or else returns -1. The function managerId () takes two arguments - the square matrix of N *N and its size N. Call managerId () from the main () output the information about the manager. Assume all diagonal elements to be 1 (as everyone knows him/herself) and there is at most one manager in the company.arrow_forwardPlease help solve the problemarrow_forward
- Exercise 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_forwardGiven a matrix of dimension m*n where each cell in the matrix can have values 0, 1 or 2 which has the following meaning: 0: Empty cell 1: Cells have fresh oranges 2: Cells have rotten oranges So we have to determine what is the minimum time required so that all the oranges become rotten. 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 cannot be rotten. Below is algorithm. 1) Create an empty Q. 2) Find all rotten oranges and enqueue them to Q. Also enqueue a delimiter to indicate beginning of next time frame. 3) While Q is not empty do following 3.a) While delimiter in Q is not reached (i) Dequeue an orange from queue, rot all adjacent oranges. While rotting the adjacents, make sure that time frame is incremented only once. And time frame is…arrow_forwardLet f ∈ C+ 2π with a zero of order 2p at z. Let r>p and m = n/r. Then there exists a constant c > 0 independent of n such that for all nsufficiently large, all eigenvalues of the preconditioned matrix C−1 n (Km,2r ∗ f)Tn(f) are larger than c.arrow_forward
- 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.arrow_forwardWe want to send n cargo by n truck. Each truck can move only one cargo and receives different costs for moving each of these cargoes. We want to move cargo with trucks so that we pay the lowest cost. First, write a backtracking algorithm for this purpose and then, explain How to reduce the branch and the complexity of the algorithm with an algorithm(Pseudocode is required for backtracking algorithm. In the branch and limit algorithm, it is sufficient to explain the limit function and the method of pruning.)arrow_forwardLet f(x) = x¹ Hx-x¹b, where H and b are constant, independent of x, and H is symmetric positive definite. Given vectors x0) and p0), find the value of the scalar a that minimizes f(x0) + ap0)). This is the formula for the stepsize ak in the linear conjugate gradient algorithm.arrow_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