Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Let C be a two dimensional parity check [16, 9] binary code. The code C encodes

ID: 3574848 • Letter: L

Question

Let C be a two dimensional parity check [16, 9] binary code. The code C encodes the nine bits (x_1, x_2, ..., x_9) by adjoining seven parity check bits p_10, p_11, p_12, p_13, p_14, p_15, p_16 so that in the matrix (x_1 x_2 x_3 p_10 x_4 x_5 x_6 p_11 x_7 x_8 x_9 p_12 p_13 p_14 p_15 p_16) each row and each column add up to 0 mod 2. The decoder received the data as a 4 times 4 matrix, and checks the sum of the entries of rows and columns. If no error has occurred, each row and column adds up to 0 mod 2. Show that pie can be chosen unambiguously. Calculate the minimal weight of the vectors in C.

Explanation / Answer


// program for checking the parity.
# include <iostream.h>
# include <math.h>
# include <stdlib.h>
# include <conio.h>

int main( ){


   char    ch;
   //d contains the sample test case values
   // matrix array contains test case values & parity values computed.
   int    d[10][10],m[10][10]={0};

   int n,i,j,p=1,crow=0,ccol=0;

   clrscr( );

   do{


       cout<<" enter size of the matrix:";
       cin>>n;

       //checking the size of the matrix is zero or not.
       if(n==0)   break;

       cout<<" Enter matrix values: ";

       //reading matrix values
       for(i=0;i<n;i++)
           for(j=0;j<n;j++)
               cin>>d[i][j];

       //copying the sample valuse into matrix.
       for(i=0;i<n;i++)
           for(j=0;j<n;j++)
               m[i][j]=abs(d[i][j]-48);

       //computing the row totals and column total.
       for(i=0;i<n;i++){
           for(j=0;j<n;j++){
               m[i][n]+=m[i][j];
               m[n][i]+=m[j][i];
           }
       }


       //checking the row and column sum is even or not.If it is odd then making the parity value to '0'.
       for(i=0;i<n;i++){
           if((m[i][n]%2)!=0 || (m[n][i]%2)!=0){

               if((m[i][n]%2)!=0)   crow++;

               else if((m[n][i]%2)!=0) ccol++;

               p=0;
           }
       }

       if(p==1) cout<<" matrix is encoded properly"<<endl;

       else if(p==0){
           if(crow>1 || ccol>1) cout<<" Corrupted,some values of matrix is encoded improperly"<<endl;

           else {
               int r=0,c=0;

               for(i=0;i<n;i++){
                   if((m[i][n]%2)!=0) r=i;

                   if((m[n][i]%2)!=0) c=i;
               }

               if(m[r][c]==0)   m[r][c]=1;

               else if(m[r][c]==1)   m[r][c]=0;

               m[r][n]=0;
               m[n][c]=0;

               for(i=0;i<n;i++){
                   m[r][n]+=m[r][i];
                   m[n][c]+=m[i][c];
               }

               if((m[r][n]%2)!=0 || (m[n][c]%2)!=0) cout<<"Corrupted"<<endl;

               else   cout<<"Chamge Bit ("<<(r+1)<<","<<(c+1)<<")"<<endl;
           }
       }

       //printing the matrix.
       cout<<" Matrix: ";
       for(i=0;i<n;i++){
           for(j=0;j<n;j++)
               cout<<m[i][j]<<" ";
           cout<<endl;

       }
       cout<<" Do you want to exit?(y/n):";
       ch=getch();
}while(ch=='y');//end of do-while loop

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote