Menu

[Solved]Create File Maincpp Containing Method Ispalindrome Using Stl Stack Stl Queue Implement Pse Q37296634

Create the file main.cpp containing the methodisPalindrome() using an STL stack and STL queue to implement thepseudocode below. In main(), prompt the user for a string (you mayassume they will type no spaces), pass the string toisPalindrome(), then tell the user whether their string was apalindrome or not.

Mainly I want the isPlindrome() function.

Background Information:

You can find the general C++ reference for the STL stack here(Links to an external site.)Links to an external site.. There issome brief sample code here (Links to an external site.)Links to anexternal site.. Note that where the book uses the peek() method theSTL stack has the top() method–they are functionally the same.

You can find the general C++ reference for the STL queue here(Links to an external site.)Links to an external site.. There issome brief sample code here (Links to an external site.)Links to anexternal site.. Note that where the book uses the enqueue() methodthe STL queue has the push() method–they are functionally thesame. Where the book uses the dequeue() method the STL queue haspop(). And where the book uses the peekFront() method the STL queuehas front().

Tests whether a given string is a palindrome isPalindrome (someString: string): boolearn ICreate an empty queue and an empty

Tests whether a given string is a palindrome isPalindrome (someString: string): boolearn ICreate an empty queue and an empty stack aQueue = a new empty queue aStack a new empty stack 1Add each character of the string to both the queue and the stack length-length of someString for (i 1 through 1ength) nextChar = ith character of somest ring aQueue.enqueue (nextChar) aStack.push (nextChar) Compare the queue characters with the stack characters charactersAreEqual true while (aQueue is not empty and charactersAreEqual) queueFront aQueue.peekFrontO stackTop aStack.peek O if (queueFront equals stackTop) aQueue.dequeue aStack.popO else charactersAreEqual false return charactersAreEqual Show transcribed image text Tests whether a given string is a palindrome isPalindrome (someString: string): boolearn ICreate an empty queue and an empty stack aQueue = a new empty queue aStack a new empty stack 1Add each character of the string to both the queue and the stack length-length of someString for (i 1 through 1ength) nextChar = ith character of somest ring aQueue.enqueue (nextChar) aStack.push (nextChar) Compare the queue characters with the stack characters charactersAreEqual true while (aQueue is not empty and charactersAreEqual) queueFront aQueue.peekFrontO stackTop aStack.peek O if (queueFront equals stackTop) aQueue.dequeue aStack.popO else charactersAreEqual false return charactersAreEqual

Expert Answer


Answer to Create the file main.cpp containing the method isPalindrome() using an STL stack and STL queue to implement the pseudoco… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *