English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am looking for the product of matrix A*B and B*A


Enter: Matrices to multiply (A,B)
Size of each matrix(mxn,nxm)
Exit: Products (C,D)
read data
read m
read n
read A
read B
for (i=1 to m and j=1 to n)
read Aij
for (i=1 to n and j= 1 to m)
read Bij
for (i=1 to m and j=1 to m)
Cij=(Aij+Bij)
for (i=1 to n and j=1 to n)
Dij =(Bij x Aij)
Show (Dij, Cij)

to determine the order I need to use n-1 and since the cycle repeats it self n-1 times, however I have two variables here n and m, also how do I determine the worst case scenario and best case scenario? Any help will be apreciated.

2006-11-01 17:28:53 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

yahoo messed my indentation...

2006-11-01 17:29:23 · update #1

1 answers

Your pseudo code to multiply matrix is not correct.
Any way assuming B is m X n matrix,
Order of this code is O(mn) because all the loop runs mn time.
There is nobest or worst case as for all matrix same value of m and n will cause same length of time.

2006-11-02 04:14:03 · answer #1 · answered by Tanaeem 4 · 0 0

fedest.com, questions and answers