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

Implement Algorithm 3 in C Here is some code to get you started. include Kiostre

ID: 3835092 • Letter: I

Question

Implement Algorithm 3 in C Here is some code to get you started. include Kiostream Rinclude cvectory Rinclude ccmath using namespace std; constexpr int N number of bits typedef enum BIT zero e, one 1 bit void displayBits(const BIT a[J, int N) display N bit number for (int i 1 i i--) if (ali BIT zero) cout: *e else cout cout CC endl. skip a line given two N bit binary numbers, a and b, return the 2N bit product void multiple(BIT answer const BIT a[J, const BIT bCJ, int N) TO DO LAB HERE test driver int main() will test this using my own numbers. BIT a[N] one, one, zero zero zero, zero, BIT b NJ one, one, one, zero, one, one, zero, one //111e 11e1 BIT pl2 NJ; answer goes here display Bits(a, N) return e; ALGORITHM 3 Multiplication of Integers. procedure multiply(a,b: positive integers) the binary expansions of a and b are (a.-1an-2...alao)2 and (be-1be-2...bibo)2. respectively) for j 0 to n -1 if b 1then cu a shifted j places else cu 0 lco.cl, ....c are the partial products) ce-i p 0 for j 0 ton -1 return plp is the value of ab

Explanation / Answer

void multiple(BIT answer[],const BIT a[],const BIT b[],int N)
{
   int i,j;
   //calculating ab
   for(i=0;i<N;i++)
   {
       if(a[i]==BIT::zero||b[i]==BIT::zero)
       {
           answer[i]=BIT::zero;  
       }
       else
       {
           answer[i]=BIT::one;  
       }
      
          
   }
  
  
   //
   for(j=0;j<N;j++)
   {
       i=0;
       if(b[j]==BIT::one)
       {
           i=N-1-j;
           if(a[i]!=BIT::zero)
           if(answer[j]==BIT::zero)
           answer[j]=BIT::one;
           else
           answer[j]=BIT::zero;
                      
       }
       else
       {
           answer[j]=BIT::zero;  
       }  
   }

}

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