Tutorials, Free Online Tutorials,It Challengers provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, core java, sql, php, c language etc. for beginners and professionals.

Breaking

Data Structure - Transpose of a Sparse Matrix Question of Pune University (MCA)

---------------------------------- " Data Structure "---------------------------------------------   
Transpose of  a Sparse Matrix 

void transpose(int b1[][3],int b2[][3]) 

    int i,j,k,n;
b2[0][0]=b1[0][1];
b2[0][1]=b1[0][0];
b2[0][2]=b1[0][2]; 
     k=1; 
     n=b1[0][2]; 
    for(i=0;i<b1[0][1];i++) /*According to column it is transposing the sparse matrix */ 
     {
        for(j=1;j<=n;j++) 
       {
if(i==b1[j][1]) 
              { 
  b2[k][0]=b1[j][1];
                b2[k][1]=b1[j][0];
                b2[k][2]=b1[j][2]; 
                k++; 
             } 
       } 
      }
}

No comments:

Post a Comment