Write an algorithm in pseudocode to perform the multiplicati

Write an algorithm in pseudocode to perform the multiplication of a matrix with a vector. b. What is the main operation of this algorithm? c. How many times is the main operation executed? d. What is the efficiency class of this algorithm?

Solution

in \'C\' Lang:

/* Description:To multiply given to matrix using arrays*/

#include<stdio.h>

#include<math.h>

main()

{

  int i,j,k;

int a,b,c;/*three variables to get the row and colum of the two matrix*/

int sum;

int m[10][10],n[10][10],l[10][10];

printf(\"The first matrix:\ \");

printf(\"Enter the number of rows and columns for the first matrix:\\t\")  ;

scanf(\"%d%d\",&a,&b);

printf(\"The Second matrix:\ \");

printf(Enter the rows and columns of the second matrix:\\t:);

scanf(\"%d%d\",&b,&c);

/* Note: For matrix multiplication the number of columns in the first matrix should be equal to the number of rows n the second message*/

printf(\":Enter the values of the first matrix:\ \");

for(i=0;i<a;i++)

   {

     for(j=0;j<b;j++)

       {

         scanf(\"%d\",&m[i][j]);

       }

   }

  printf(\"Enter the values of the second matrix:\ \");

  for(i=0;i<b;i++)

   {

     for(j=0;j<c;j++)

      {

        scanf(\"%d\",&n[i][j]);

      }

   }

   for(i=0;i<a;i++)

     {

    for(j=0;j<c;j++)

     {

       sum=0;

       for(k=0;k<b;k++)

        {

          sum=sum+(m[i][k]*n[k][j]);

          l[i][j]=sum;

        }

     }

  }

  printf(\"The multiplied matrix is:\ );

  for(i=0;i<a;i++)

   {

     for(j=0;j<c;j++)

      {

         printf (\"%d\",l[i][j]);

         printf(\"\\t\");

      }

       printf(\"\ \");

   }

MAIN OPERATION and EFFICIENT OPERATION

printf(\"The multiplied matrix is:\ );

  for(i=0;i<a;i++)

   {

     for(j=0;j<c;j++)

      {

         printf (\"%d\",l[i][j]);

         printf(\"\\t\");

      }

       printf(\"\ \");

   }

number of times of operation execution...

it will be based on the input in the first two matrices

 Write an algorithm in pseudocode to perform the multiplication of a matrix with a vector. b. What is the main operation of this algorithm? c. How many times is
 Write an algorithm in pseudocode to perform the multiplication of a matrix with a vector. b. What is the main operation of this algorithm? c. How many times is
 Write an algorithm in pseudocode to perform the multiplication of a matrix with a vector. b. What is the main operation of this algorithm? c. How many times is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site