Question: Java Question: * equalQueues * two queues are equal if they are the same size and all corresponding items are the same * precondition: input
Java Question:
* equalQueues
* two queues are equal if they are the same size and all corresponding items are the same
* precondition: input queues q1, q2 may be empty
* postconditions:
* return true if the two queues are identical and false otherwise
* original queues are unchanged
*
* you may use: basic java arrays, Stack<>, Queue<> from algs13
* you may not use any other Java classes, algorithms without permission
*
* your solution must be all client code: you may not alter the original Stack, Queue classes
*
* you MAY NOT use the toString method of the Stack or Queue classes
*
* In the examples below, the left-most values are at the front of the queues
* Examples:
* q1: abcd , q2: abcd equalQueues(q1,q2) --> true
* q1: abc , q2: xy equalQueues(q1,q2) --> false
* q1: a , q2: xyz equalQueues(q1,q2) --> false
* q1: a , q2: equalQueues(q1,q2) --> false
* q1: a , q2: a equalQueues(q1,q2) --> true
*
*/
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
