Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 22.4, Problem 22.4.2CP
Program Plan Intro
Time complexity to add two n x m matrices:
The time complexity to add two n x m matrices is: “
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Following code is a part of an algorithm where A = [a; ;] is
an N x N matrix with a;i = a(i, j), x, y, b are vectors of length N.
Count the total number of operations (addition/subtraction and multi-
plication/division) for the code below in terms of N (Give a simplified
answer in terms of N):
Begin Algorithm
fct = 2
sum
for i = 1 to N
x(i)
y(i) = Fa
end i loop
for j = 1 to N
suml = 0
for k = j+1 to N
suml = suml+a(j,k) * y(k)
end k loop
r(j)
end j loop
sum = 10 + sum1 * fct
b(j)-sum
a(j, j)
End Algorithm
Array P = [40, 30, 25, 10, 35, 5, 20]
Suppose the dimension of 6 matrices (A1, A2 … A6) are given by array P
A1 is a P[0] x P[1] matrix
A2 is a P[1] x P[2] matrix
.
.
.
A6 is a P[5] x P[6]
a) Find the minimum number of scalar multiplications necessary to calculate the product of all the 6 matrices (A1.A2.A3.A4.A5.A6) and show the parenthesization for this multiplication.
• Solve the problem manually (you need not to write any code) using bottom-up tabulation approach. Compute and show the ‘m’ matrix and ‘s’ matrix to solve your problem.
We are given a code symmetry, that takes an n x n matrix as its argument. It returns true if the matrix is symmetric and false if it is not. The run time of the code is calculated by counting how many times the /= comparison is executed.
procedure symmetry(M)
for x:=1 to (n-1)
for y:=(i+1) to n
if mxy /= myx then return false
else return true
(a) Calculate the best case run time for symmetry (will be a number).
(b) Calculate the worst case run time for symmetry (will be a polynomial in n, it will be helpful to draw matrices of different sizes and compare the number of comparisons to find a pattern).
(c) Determine the worst case run time in big O notation
(d) Using the following definition of big O notation, prove the answer to (c)
Definition: Let f and g be functions from the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is O(g(x)) if there are constants C and k such that whenever x > k. [This is…
Chapter 22 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 22.2 - Prob. 22.2.1CPCh. 22.2 - What is the order of each of the following...Ch. 22.3 - Count the number of iterations in the following...Ch. 22.3 - How many stars are displayed in the following code...Ch. 22.3 - Prob. 22.3.3CPCh. 22.3 - Prob. 22.3.4CPCh. 22.3 - Example 7 in Section 22.3 assumes n = 2k. Revise...Ch. 22.4 - Prob. 22.4.1CPCh. 22.4 - Prob. 22.4.2CPCh. 22.4 - Prob. 22.4.3CP
Ch. 22.4 - Prob. 22.4.4CPCh. 22.4 - Prob. 22.4.5CPCh. 22.4 - Prob. 22.4.6CPCh. 22.5 - Prob. 22.5.1CPCh. 22.5 - Why is the recursive Fibonacci algorithm...Ch. 22.6 - Prob. 22.6.1CPCh. 22.7 - Prob. 22.7.1CPCh. 22.7 - Prob. 22.7.2CPCh. 22.8 - Prob. 22.8.1CPCh. 22.8 - What is the difference between divide-and-conquer...Ch. 22.8 - Prob. 22.8.3CPCh. 22.9 - Prob. 22.9.1CPCh. 22.9 - Prob. 22.9.2CPCh. 22.10 - Prob. 22.10.1CPCh. 22.10 - Prob. 22.10.2CPCh. 22.10 - Prob. 22.10.3CPCh. 22 - Program to display maximum consecutive...Ch. 22 - (Maximum increasingly ordered subsequence) Write a...Ch. 22 - (Pattern matching) Write an 0(n) time program that...Ch. 22 - (Pattern matching) Write a program that prompts...Ch. 22 - (Same-number subsequence) Write an O(n) time...Ch. 22 - (Execution time for GCD) Write a program that...Ch. 22 - (Geometry: gift-wrapping algorithm for finding a...Ch. 22 - (Geometry: Grahams algorithm for finding a convex...Ch. 22 - Prob. 22.13PECh. 22 - (Execution time for prime numbers) Write a program...Ch. 22 - (Geometry: noncrossed polygon) Write a program...Ch. 22 - (Linear search animation) Write a program that...Ch. 22 - (Binary search animation) Write a program that...Ch. 22 - (Find the smallest number) Write a method that...Ch. 22 - (Game: Sudoku) Revise Programming Exercise 22.21...Ch. 22 - (Bin packing with smallest object first) The bin...Ch. 22 - Prob. 22.27PE
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
- True or False The inverse of a matrix M can be calculated in Python with the command Inverse=np.linalg.inv(M)arrow_forwardGiven the following matrix: a= 3 -5 7 -9 11 13 15 17 19 Set the values for matrix a that are positives to zero. add row as fourth row. delete second column. use matlabarrow_forwardLet 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_forward
- Computer Science How would you modify Strassen's algorithm to multiply n n matrices in which n is not an exact power of 2? Explain how your algorithm works for the case where n = 30.arrow_forwardhand write pzlzzarrow_forwardWrite the following set of equations in matrix form (or array form): 50=5x₂ - 7x₂ 4x₂ + 7x₂ +30=0 x₁ - 7x₂ = 40-3x₂ + 5x₁ Use Python to solve for the unknowns. In addition, compute the transpose and inverse of the coefficient matrix.arrow_forward
- Write a phyton program that solves the following given problems: 1. Perform Matrix Multiplication. Multiply matrix [A] and [B]arrow_forwardQ2\ Compute IDFT using Matrix method for X(k) = [6, - 2 + 2j, -2, - 2 - 2 - 2j] then calculate the number of addition and multiplication for FFT and DFT?arrow_forwardAssume you have a matrix with dimensions 1000x1000 and you want to compute its transpose. What is the time complexity of this operation?arrow_forward
- Create Python code for multiplication of any two sparse matrices. Hint: specify the matrices S1 and S2 in CSR format first, then multiply them and print the product in both CSR and dense matrix formats.arrow_forwardDefine a matrix with ones numbers with size 3x4 جابتك Replace the first row with random numbers * Remove the last row إجابران Multiply the diagonal numbers with * maximum number witharrow_forwardi need the answer quicklyarrow_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