1. You are given a number N. 2. You have to generate and print all n-bit grey code sequences. 3. In a grey code sequence, successive terms differ by one bit. 4. Check sample output for more information.
Input Format
A number N
Output Format
Check the sample ouput and question video.
Constraints
1 <= N <= 10
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
3
Output
0 0 0 0 0 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1 1 0 0