OK heres my assignment question- Write a program that, given

*n*and alphabet

*Z*as inputs, outputs all strings of length

*n*over the alphabet

*Z*.

now alphabet here means a string array where for example Z = {a, c} can be an alphabet of 2 symbols and if I want to out all the strings of length 3, this is what I should get (9 strings in total) -

aaa

aac

aca

caa

acc

cac

cca

ccc

Now i dont have any code as I am still struggling with concepts... First idea I had in mind was like to do a matrix of width n and length = total number of strings.... but, then how do I fill up the matrix??

I have no idea how to approach this problem - there is another idea i came up with which was like initialising the sequence of length n to the first symbol of the alphabet ..But again how would I come around to changing the sequence - I cant figure it out.. any ideas??