Literal homework text:
"
...Using recursion, add each alphanumeric character to both a stack and a queue.
Using recursion, pop a character from the stack and dequeue a character from the queue..."
The full assignment is to use stacks and queues to check to see if the string is a palindrome.
I have a fully functioning stack and queue, but i don't know how to recursively push and enqueue my values. any tips would help!
Here is my current code:
int main()
{
stack* stak = new stack();
Queue* que = new Queue();
string name;
char charString[100];
getline(cin, name); //priming read
//will loop until q is entered
while(name != "q") {
strcpy(charString, name.c_str());
for(int i = 0; i < strlen(charString); i++) {
lowercase(name[i]);
//this function just checks to see if character is alphanumeric
//if it's not, it moves to the next index
if(discardsymbols(name[i], i) == i) {
stak->push(name[i]);
que->enqueue(name[i]);
}
}
getline(cin, name);
}
return 0;
}