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 4.2, Problem 6E
Program Plan Intro
To find the running time complexity of multiplication of a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Using Java
Modify the program 1 to compute the multiplication of two vectors with the sizes mx1 and 1xn. The result is a matrix mxn computed as follows: the element on the position r and c in the product will be equal with m1[r][0]*m2[0][c].
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.
Create a row vector of 1's that has 4 rows. Now Create a column vector of 1's that has 4 columns. Using matrix multiplication, multiply both of these to get a 4x4 matrix and display the resulting matrix. Using matlab, do this. Please answer it correctly and don’t copy from anywhere otherwise it will be downvoted.
Chapter 4 Solutions
Introduction to Algorithms
Ch. 4.1 - Prob. 1ECh. 4.1 - Prob. 2ECh. 4.1 - Prob. 3ECh. 4.1 - Prob. 4ECh. 4.1 - Prob. 5ECh. 4.2 - Prob. 1ECh. 4.2 - Prob. 2ECh. 4.2 - Prob. 3ECh. 4.2 - Prob. 4ECh. 4.2 - Prob. 5E
Ch. 4.2 - Prob. 6ECh. 4.2 - Prob. 7ECh. 4.3 - Prob. 1ECh. 4.3 - Prob. 2ECh. 4.3 - Prob. 3ECh. 4.3 - Prob. 4ECh. 4.3 - Prob. 5ECh. 4.3 - Prob. 6ECh. 4.3 - Prob. 7ECh. 4.3 - Prob. 8ECh. 4.3 - Prob. 9ECh. 4.4 - Prob. 1ECh. 4.4 - Prob. 2ECh. 4.4 - Prob. 3ECh. 4.4 - Prob. 4ECh. 4.4 - Prob. 5ECh. 4.4 - Prob. 6ECh. 4.4 - Prob. 7ECh. 4.4 - Prob. 8ECh. 4.4 - Prob. 9ECh. 4.5 - Prob. 1ECh. 4.5 - Prob. 2ECh. 4.5 - Prob. 3ECh. 4.5 - Prob. 4ECh. 4.5 - Prob. 5ECh. 4.6 - Prob. 1ECh. 4.6 - Prob. 2ECh. 4.6 - Prob. 3ECh. 4 - Prob. 1PCh. 4 - Prob. 2PCh. 4 - Prob. 3PCh. 4 - Prob. 4PCh. 4 - Prob. 5PCh. 4 - Prob. 6P
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
- What is the running time of the following matrix multiplication method?// square matrix multiplication// m1, m2, and result are n by n arraysfor (int row = 0; row < n; row++){for (int col = 0; col < n; col++){int sum = 0;for (int entry = 0; entry < n; entry++){sum = sum + m1[row][entry]*m2[entry][col];}result[row][col] = sum;}}arrow_forwardWrite a code in "C++"that can swap all the values of its first row with its last row in a [n×m] matrix After swapping, add all the values of the last column.(using C++ only)arrow_forwardCan you answer with using Python programming language without using input ? A 2D matrix can be represented as a list and a column count value in Python. For example, the 3x3 matrix 1 2 3 4 5 6 7 8 9 can be row-wise represented as ([1,2,3,4,5,6,7,8,9], 3), where the number 3 represents the number of columns in the matrix. Similarly, 1 3 5 2 4 6 becomes ([1,3,5,2,4,6], 3). A submatrix can be defined as an (l,r,t,b) tuple, where l and r are left and right column indices, and t and b are top and bottom row indices (all inclusive). Write a function that takes a tuple containing the list representing a matrix, and the column count of the matrix, along with another tuple representing a specific submatrix, and returns the list representation of the submatrix along with its column count as a tuple. For example, given submatrix(([1,2,3,4,5,6,7,8,9,10,11,12], 4), (1,2,0,1)) returns: ([2,3,6,7], 2) because, ([1,2,3,4,5,6,7,8,9,10,11,12], 4) represents: 1 2 3 4 5 6 7 8 9 10 11 12 and (1,2,0,1)…arrow_forward
- Write a code in "C"that can swap all the values of its first row with its last row in a [n×m] matrix After swapping, add all the values of the last column.arrow_forwardIn python, Construct an n x n matrix, where you can establish a pattern of 1s,2s,3s, etc in the outer row-column, successively until you completely fill the matrix. Example: Ask for the user the size of the matrix (5x5) then automatically generates the following:arrow_forwardGet the time complexity function from the pseudocode for adding 2 matrices below // add two matricesfor(i = 0 ; i < rows; i++){for(j = 0; j < columns; j++)matrix2[i][j] = matrix1[i][j] + matrix2[i][j];}// display the resultfor(i = 0 ; i < rows; i++){for(j = 0; j < columns; j++){printf("%d ", matrix2[i][j]);}printf("\n");}arrow_forward
- Let us consider multiplying a 5 by 5 sparse matrix with a 5 by 3 sparse matrix shown in picture. make Python code to implement multiplication of these two sparse matricesarrow_forwardWrite a Python program for the following, Write the uncoded row matrices of size for the message MEET ME MONDAY.SOLUTION Partitioning the message (including blank spaces, but ignoring punctuation) into groups ofthree produces the following uncoded row matrices. [13 5 5] [20 0 13] [5 0 13] [15 14 4] [1 25 0] M E E T _ M E _ M O N D A Y _ Note that a blank space is used to fill out the last uncoded row matrix. Use the matrix A = [[1,-2,2], [-1,1,3], [1,-1,-4]]To encode a message, choose an invertible matrix and multiply the uncoded rowmatrices (on the right) by to obtain coded row matrices.arrow_forwardWhat is the running time of the following matrix multiplication method?// square matrix multiplication// m1, m2, and result are n by n arraysfor (int row = 0; row < n; row++){for (int col = 0; col < n; col++){int sum = 0;for (int entry = 0; entry < n; entry++){sum = sum + m1[row][entry]*m2[entry][col];}result[row][col] = sum;}} give ans in 20 minutesarrow_forward
- Compare between the brute force and the faster D&C implementation by calculating the number of multiplications for different n (powers of 2) sizes of randomly initialized matrices.arrow_forwardWrite a program to read a square matrix and then print the elements above the principal diagonal. (By matlab)arrow_forwardA matrix is an array of numbers of size m by n (i.e., m x n). When we multiply 2 matrices, we multiply the matching numbers, then sum them up. Multiplying a matrix of size m x n with another matrix of size n x q will result in a matrix of size m x q. An example is shown in Figure 1: [ ? ? ? ? ? ? ] x [ ? ? ? ? ] = [ ?? +?? ?? + ?? ?? + ?? ?? + ?? ?? + ?? ?? + ?? ] Matrix 3 x 2 Matrix 2 x 2 Matrix 3 x 2 Figure 1: Multiplication of Matrix 3 x 2 and 2 x 2 Write a C++ program that multiplies 2 matrices and return the sum of the transposed matrix. Your program shall include the following: a) Define two 2 dimensional arrays, M and N that each represents a matrix of size 3 x 2 and a matrix of size 2 x 2. Request the user to enter the values for the 2 arrays using advanced pointer notations (refer to your slides for the list of array pointer notations). b) Create a function named multMatrix() that passes as arguments, the values of array M and N, multiplies them and store the results in a new…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