Matrix Chain Multiplication - My articles - Publisher - Information Technology
Sunday, 2016-12-04, 5:10 PM
ebooks Programming Computer Science
Welcome Guest | RSS
Site menu
Section categories
My articles [23]
Main » Articles » My articles

Matrix Chain Multiplication
#include<stdio.h>

void main()
 {
  int mov_cost=1;
  int cost1,cost2;
  int Array[2][6]={{0,3,5,3,2,1},{0,4,2,1,5,9}};


  for(int i=1;i<6;i++)

   {
     cost1=Array[0][i-1]+Array[0][i];
     cost2=Array[1][i-1]+Array[0][i]+mov_cost;
     if (cost1<cost2) Array[0][i]=cost1;
     else
      Array[0][i]=cost2;

     cost1=Array[1][i-1]+Array[1][i];
     cost2=Array[0][i-1]+Array[1][i]+mov_cost;
     if (cost1<cost2) Array[1][i]=cost1;
       else
      Array[1][i]=cost2;

  }
   printf(" \n");
  for(i=1;i<6;i++){
    printf(" %d",Array[0][i]);}

  printf(" \n");
  for(i=1;i<6;i++){
    printf(" %d",Array[1][i]);
}
  }

Category: My articles | Added by: Sumrat (2012-03-25)
Views: 271 | Comments: 3 | Rating: 0.0/0
Total comments: 1
1  
ikqfwso

Name *:
Email *:
Code *:
Our poll
Rate my site
Total of answers: 152
Statistics

Total online: 1
Guests: 1
Users: 0
Login form