I have just made a queue class and I now have to use it to do this.
Write a c++ program to generate all strings using A,B,and C as the letters.
The strings must be generated in the following order:
A
B
C
AA
AB
AC
BA
BB
BC
CA
CB
CC
AAA
AAB
AAC
ABA
ABB
ABC
ACA
ACB
ACC
etc.
It’s supposed to do this until my queue overflows.
Now, I simply don’t understand the algorithm the teacher suggested using, which is this.
Start with A and B and C in the queue.
“Remove it Display it then Add Add Add ”
The add add add thing throws me off, how does it accomplish getting these letters in this particular order?
Let our behavior be:
Our flow will be something like:
If we pretend our function is
Get it now?