Construct an array whose Prefix XOR array starting from X is an N | Function to print the required array ; Iteratie from 1 to N ; Print the i - th element ; Update prev_xor to i ; Driver Code ; Given Input ; Function Call
def GenerateArray ( N , X ) : NEW_LINE INDENT prev_xor = X NEW_LINE for i in range ( 1 , N + 1 , 1 ) : NEW_LINE INDENT print ( i ^ prev_xor , end = " " ) NEW_LINE if ( i != N ) : NEW_LINE INDENT print ( " ▁ " , end = " " ) NEW_LINE DEDENT prev_xor = i NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 4 NEW_LINE X = 3 NEW_LINE print ( " The ▁ generated ▁ array ▁ is ▁ " , end = " " ) NEW_LINE GenerateArray ( N , X ) NEW_LINE DEDENT