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 6, Problem 3P
(a)
Program Plan Intro
To draw a 4 X 4 young tableau matrix.
(b)
Program Plan Intro
To argue the fact of emptiness and fullness of Young tableau
(c)
Program Plan Intro
To give an
(d)
Program Plan Intro
To insert a new element in O( m+n ) time
(e)
Program Plan Intro
To sort n*n numbers in O ( n*n*n ) time
(f)
Program Plan Intro
To find a particular element from Young tableau in O( m+n ) time.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Question 2) We have N jobs and N workers to do these jobs. It is known at what cost each worker will do each job (as a positive numerical value). 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, write the algorithm as pseudocode, whose 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, and that tries to reach the solution with GREEDY technique. Explain in what sense your algorithm exhibits greedy behavior. What is the time complexity of your algorithm? Interpret if your algorithm always produces the best (optimum) result for each instance of the problem.
Single Point based Search:
Fair share problem: Given a set of N positive integers S={x1, x2, x3,…, xk,… xN}, decide whether S can be partitioned into two sets S0 and S1 such that the sum of numbers in S0 equals to the sum of numbers in S1. This problem can be formulated as a minimisation problem using the objective function which takes the absolute value of the difference between the sum of elements in S0 and the sum of elements in S1. Assuming that such a partition is possible, then the minimum for a given problem instance would have an objective value of 0. A candidate solution can be represented using a binary array r=[b1, b2, b3,…, bk,… bN], where bk is a binary variable indicating which set the k-th number in S is partitioned into, that is, if bk =0, then the k-th number is partitioned in to S0, otherwise (which means bk =1) the k-th number is partitioned in to S1. For example, given the set with five integers S={4, 1, 2, 2, 1}, the solution [0,1,0,1,1] indicates that S is…
(Sparse matrix–vector product) Recall from Section 3.4.2 that a matrix is said to be sparse if most of its entries are zero. More formally, assume a m × n matrix A has sparsity coefficient γ(A) ≪ 1, where γ(A) ≐ d(A)/s(A), d(A) is the number of nonzero elements in A, and s(A) is the size of A (in this case, s(A) = mn). 1. Evaluate the number of operations (multiplications and additions) that are required to form the matrix– vector product Ax, for any given vector x ∈ Rn and generic, non-sparse A. Show that this number is reduced by a factor γ(A), if A is sparse. 2. Now assume that A is not sparse, but is a rank-one modification of a sparse matrix. That is, A is of the form à + uv⊤, where à ∈ Rm,n is sparse, and u ∈ Rm, v ∈ Rm are given. Devise a method to compute the matrix–vector product Ax that exploits sparsity.
Chapter 6 Solutions
Introduction to Algorithms
Ch. 6.1 - Prob. 1ECh. 6.1 - Prob. 2ECh. 6.1 - Prob. 3ECh. 6.1 - Prob. 4ECh. 6.1 - Prob. 5ECh. 6.1 - Prob. 6ECh. 6.1 - Prob. 7ECh. 6.2 - Prob. 1ECh. 6.2 - Prob. 2ECh. 6.2 - Prob. 3E
Ch. 6.2 - Prob. 4ECh. 6.2 - Prob. 5ECh. 6.2 - Prob. 6ECh. 6.3 - Prob. 1ECh. 6.3 - Prob. 2ECh. 6.3 - Prob. 3ECh. 6.4 - Prob. 1ECh. 6.4 - Prob. 2ECh. 6.4 - Prob. 3ECh. 6.4 - Prob. 4ECh. 6.4 - Prob. 5ECh. 6.5 - Prob. 1ECh. 6.5 - Prob. 2ECh. 6.5 - Prob. 3ECh. 6.5 - Prob. 4ECh. 6.5 - Prob. 5ECh. 6.5 - Prob. 6ECh. 6.5 - Prob. 7ECh. 6.5 - Prob. 8ECh. 6.5 - Prob. 9ECh. 6 - Prob. 1PCh. 6 - Prob. 2PCh. 6 - Prob. 3P
Knowledge Booster
Similar questions
- Search a sorted matrix: The input consists of a real number x and a matrix A[1..n, 1..m] of nm real values, where A[i, 1..m] and A[1..n, j] are the rows and columns, respectively, of the matrix. The objective is to either state that all of the members of A are greater than x or to locate the largest array entry A[i, j] that is less than or equal to x. Create and evaluate an iterative approach for this issue that looks at the least amount of matrix entries feasible. If you think the issue can be resolved with a straightforward binary search, think twice.arrow_forwardType in Latex **Problem**. Let $$A = \begin{bmatrix} .5 & .2 & .3 \\ .3 & .8 & .3 \\ .2 & 0 & .4 \end{bmatrix}.$$ This matrix is an example of a **stochastic matrix**: its column sums are all equal to 1. The vectors $$\mathbf{v}_1 = \begin{bmatrix} .3 \\ .6 \\ .1 \end{bmatrix}, \mathbf{v}_2 = \begin{bmatrix} 1 \\ -3 \\ 2 \end{bmatrix}, \mathbf{v}_3 = \begin{bmatrix} -1 \\ 0 \\ 1\end{bmatrix}$$ are all eigenvectors of $A$. * Compute $\left[\begin{array}{rrr} 1 & 1 & 1 \end{array}\right]\cdot\mathbf{x}_0$ and deduce that $c_1 = 1$.* Finally, let $\mathbf{x}_k = A^k \mathbf{x}_0$. Show that $\mathbf{x}_k \longrightarrow \mathbf{v}_1$ as $k$ goes to infinity. (The vector $\mathbf{v}_1$ is called a **steady-state vector** for $A.$) **Solution**. To prove that $c_1 = 1$, we first left-multiply both sides of the above equation by $[1 \, 1\, 1]$ and then simplify both sides:$$\begin{aligned}[1 \, 1\, 1]\mathbf{x}_0 &= [1 \, 1\, 1](c_1\mathbf{v}_1 +…arrow_forwardс++ The table of the football championship is given by a square matrix of order n, in which all elements belonging to the main diagonal are equal to zero, and each element not belonging to the main diagonal is equal to 2, 1 or 0 (the number of points scored in the game: 2—win, 1 — draw, 0—loss).Determine the numbers of the teams that passed the championship without defeat. Input: 5 0 1 0 2 2 2 0 1 2 1 0 1 0 2 0 2 2 2 0 1 1 0 2 2 0 Output: 1 3arrow_forward
- A magic square of order n is an arrangement of the integers from 1 to n2 in an n × n matrix, with each number occurring exactly once, so that each row, each column, and each main diagonal has the same sum Design and implement an exhaustive-search algorithm for generating all magic squares of order n.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_forwardSearch a sorted matrix: The input consistsof a real number x and a matrix A[1..n, 1..m] of nm real numbers such that each rowA[i, 1..m] is sorted and each column A[1..n, j] is sorted. The goal is to find the maximum array entry A[i, j] that is less than or equal to x, or report that all elements of Aare larger than x. Design and analyze an iterative algorithm for this problem that examines as few matrix entries as possible. Becareful if you believe that a simple binarysearch solves the problem. make a lower bound, and recursive algorithm.arrow_forward
- Search a sorted matrix: The input consistsof a real number x and a matrix A[1..n, 1..m] of nm real numbers such that each rowA[i, 1..m] is sorted and each column A[1..n, j] is sorted. The goal is to find the maximum array entry A[i, j] that is less than or equal to x, or report that all elements of Aare larger than x. Design and analyze an iterative algorithm for this problem that examines as few matrix entries as possible. Becareful if you believe that a simple binarysearch solves the problem.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_forwardCorrect answer will be upvoted else Multiple Downvoted. Computer science. observe each tidy initially how about we characterize what a tidy in the matrix is. A bunch of matrix cells is called a tidy of tallness k with beginning at point (x,y) if: All cells in the set contain an "*". For each 1≤i≤k all cells with the line number x+i−1 and sections in range [y−i+1,y+i−1] should be a part of the set. All different cells cannot have a place with the set. Presently Rick wants to know the number of tidies his n×m matrix contains. Assist Rick with tackling this issue. Input Each test contains at least one experiments. The primary line contains the number of experiments t (1≤t≤10). The primary line of each experiment contains two integers n and m (1≤n,m≤500) — matrix size. Next n lines of each experiment contain m characters ci,j — matrix substance. It is guaranteed that ci,j is either a "." or an "*". It is guaranteed that the amount of n⋅m over all experiments doesn't…arrow_forward
- Computer Science Given an N x N matrix M with binary entries i.e every entry is either 1 or 0. You are told that every row and every column is sorted in increasing order. You are required to output a pair (i,j) with 1 <= i and j <= n corresponding to the entry of the matrix satisfying Mij = 1 and Mrs = 0 for all 1 <= r <= i and 1 <= s <= j except for Mij Informally this includes the entry of M = 1 and is closest to the top left corner. for example: M = [ 0 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1] output is (2,3) or (1,4) M = [ 0 1 1 1 1 1 1 1 1] output could be (1,2) or (2,1) Design a divide and conquer algorithm, explain correctness and runtime of the algorithm.arrow_forwardGiven an n×n matrix M in which every entry is either a 0 or 1. Present an algorithm that determines if ∃i, 1 ≤ i ≤ n, such that M[i, j] = 0 and M[j, i] = 1, ∀j, 1 ≤ j ≤ n ∧ j 6= i, using examining an entry of M as the key operation. Your algorithm must examine at most 3n − ⌊lg n⌋ − 3 entries of M.arrow_forwardMatrix multiplication plays an important role in a number of applications. Two matrices can only be multiplied if the number of columns of the fi rst matrix is equal to the number of rows in the second.Let’s assume we have an m × n matrix A and we want to multiply it by an n × p matrix B. We can express their product as an m × p matrix denoted by AB (or A ⋅ B). If we assign C = AB, and ci,j denotes the entry in C at position (i, j), then for each element i and j with 1 ≤ i ≤ m and 1 ≤ j ≤ p. Now we want to see if we can parallelize the computation of C. Assume that matrices are laid out in memory sequentially as follows: a1,1, a2,1, a3,1, a4,1, ..., etc.Assume that we are going to compute C on both a single core shared memory machine and a 4-core shared-memory machine. Compute the speedup we would expect to obtain on the 4-core machine, ignoring any memory issues.Repeat above Exercise, assuming that updates to C incur a cache miss due to false sharing when consecutive elements are in a…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