Generate Grey Code Sequences
Submissions: 2430   Accuracy:

44.67%

  Difficulty: Easy   Marks: 2

Given a number N, your task is to complete the function which generates all n-bit grey code sequences, a grey code sequence is a sequence such that successive patterns in it differ by one bit.

Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N.

Output:
For each test case in print the generated grey code sequences separated by space.

Constraints:
1<=T<=10
1<=N<=10

Example(To be used for expected output):
Input:
2
2
1

Output:
00 01 11 10
0 1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal
Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.