Trace the palindrome-recognition algorithm described in this section for eachof the following strings of characters:

a. abcda
b. radar
What will be an ideal response?


a.When the for loop ends, the stack and queue are as follows:
Stack: a d c b a ?bottom
Queue: a b c d a ?back
The a at the top of the stack matches the a at the front of the queue. After removing the a from both containers, the d at the top of the stack does not match the b at the front of the queue, so the string is not a palindrome.
b.When the for loop ends, the stack and queue are as follows:
Stack: radar?bottom
Queue: radar?back
The letters that you remove from the stack and the queue are the same, so the string is a palindrome.

Computer Science & Information Technology

You might also like to view...

What is the difference between a unary and a binary operator?

What will be an ideal response?

Computer Science & Information Technology

A ________ is software that captures every action undertaken by an individual user of a suspect machine

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Thea:activestyle rule must follow thea:visitedstyle rule to be effective.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Visual Studio 2015 provides a tool to print the user interface designed in the application.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology