Question: class Queue { private int front, rear, maxSize; private int queue[]; Queue(int c) { front = 0; rear = -1; maxSize = c; queue =

class Queue { private int front, rear, maxSize;

private int queue[];

Queue(int c) { front = 0; rear = -1;

maxSize = c;

queue = new int[maxSize]; }

Based on the above class declaration, write the following methods.

Write splitQ method that splits the elements of a queue (q1) in two by assigning first half values to a new queue (q2) and keeping only last half values in (q1). (6 points)

Example:

q1 holds 20 <-- 30 <-- 40 <-- 50 <-- 60 <-- 70 After calling split method q2 will hold 20 <-- 30 <-- 40 and q1 will hold 50 <-- 60 <-- 70

void splitQueue(Queue q1){ Queue q2 = new Queue(q1.maxSize);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!