Question: In general, n-bit Gray code: (1) Reverse copy the (n-1)-bit Gray code: (2) Add 0 to the left of the first half and add 1

In general, n-bit Gray code: (1) Reverse copy the (n-1)-bit Gray code: (2) Add 0 to the left of the first half and add 1 to the left of the second half. Write a C++ recursive function for generating an n-bit Gray code using the above algorithm. You must use the code below. Do not use other algorithms nor copy from what you find online. I will not accept your assignment if you do not use this algorithm #include using namespace std: void grayCode (int **a, int grayCodeSize) { if (grayCodeSize grayCodeSize - 1)//condition for returning from recursive return: //Fill in your code here. next_column**: j *- 2: grayCode(a, grayCodeSize): } int main(void) { int grayCodeSize;//grayCodeSize is size of the Gray Code in number of bits int size = 1;//size will be set to 2grayCodeSize cout > grayCodeSize;//the number of bits of a Gray code cout = 0: j--) cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
