how to use recursion to send alphanumeric characters onto a stack and a queue?


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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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;
}
Topic archived. No new replies allowed.