Member Avatar

Moody_1

Consider all the sequences with length (0 < N < 44), containing only the elements 0 and 1, and no two ones are adjacent (110 is not a valid sequence of length 3, 0101 is a valid sequence of length 4). Write a program which finds the sequence, which is on K-th place in the lexicographically sorted in ascending order collection of the described sequences.

For Example:
FOR N=2
00
01
10

FOR N=3
000
001
010
100
101

User will enter a Kth number that will start searching from Kth term in the given sequence.
for Example:

Input:
N=3
K=4

Output: 001

Please answer me if u got any logic for that...

This reeks of homework. Please prove that you've tried to solve the problem if you want any help. Being fed an answer doesn't teach you anything except how to be helpless.