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

Write a function to perform binary shift right operation . Your function will ac

ID: 3775135 • Letter: W

Question

Write a function to perform binary shift right operation . Your function will accept a binary vector (a sequence of 0s and 1s), and will shift the digits in your binary vector one digit to the right. The function will replace the first digit with one 0.

Example: Assume input x =[ 1 0 1 1 0 0 0 1], then the output of your function should be y =[ 0 1 0 1 1 0 0 0].

Note: Your function should check for the vector to be a binary vector. That is all the element in your input vector should be either 0 or 1 . If your vector is not a binary vector, the function returns ' ERROR '.

Explanation / Answer

Program is as follows:

class Test {

    public static void main(String args[])

{

       int x = -4;

       System.out.println(x>>1);  

       int y = 4;

       System.out.println(y>>1);  

    }   

}

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