Question
Write the pseudo code for an algorithm isQSimilar(Q1,Q2) to check whether two queues, Q1 and Q2, are similar or not. (i.e. same elements in both
Write the pseudo code for an algorithm isQSimilar(Q1,Q2) to check whether two queues, Q1 and Q2, are similar or not. (i.e. same elements in both queues and the same order of elements) At the end of the comparison, both queues should look unchanged. The only basic operations that you can use on the queues are the following: addQueue(), deleteQueue(), Qsize(), Rear() and Front(). Feel free to use an additional number of stacks and queues. If you decided to use stacks, the only operations available to use on the stack are: push(), pop(), top(), and isEmptyStack().
Given a queue of characters, write the pseudo code for an algorithm isQPalindrome() which checks whether the elements in the queue form a palindrome of not. The only basic operations that you can use on the queue are the following: addQueue(), deleteQueue(), Qsize(), Rear() and Front(). Feel free to use an additional number of stacks and queues. If you ended up using a stack, then the only operations available to use on the stack are: push(), pop(), top(), and isEmptyStack().
For example: if Q = [a,b,c,d], then isQPalindrome(Q) should return false. if Q = [a,b,c,b,a], then isQPalindrome(Q) should return true.
Analyze the complexity of your algorithm as a function of the size of the stack (O(?)). Briefly justify your answer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started