Question: a) ( 3 pts ) Using a circular shift print all values of the five queues, authorizing to lose the values in the queue. Example

a) (3 pts) Using a circular shift print all values of the five queues, authorizing to lose the values in the queue.

Example for the five next queues as input:

6 3 9

2 1 1

1 2 2

7 9 1

1 3 2

You should print:

6 2 1 7 1 3 1 2 9 3 9 1 2 1 2

b)

Let D a declaration and creation of an array of 5 Queues implemented as Singly Linked Lists, using the Java classes Queue and LinkeList of the Java Library. Each queue contains a list of integers.

Queue D[] = new Queue[5]; // here the array of queues

for (int i=0;i<5;i++) D[i]= new LinkedList();

Example:

Input: D[0] contains 6 3 9

Output: 6 3 9 and D[0] contains 6 3 9

(2 pts) Write a function to print all integer values of D[0], without losing elements of D[0], assuming that class queue has the following methods:

Dequeue() that deletes the front and returns an integer,

Enqueue(int v) for adding v to the rear of the queue

Size() returns the size of the queue

isEmpty() returns true if the queue is empty.

void printQ (queue Q)

{

}

c)

Let S the declaration and Creation of an array of 27 lists of integers:

LinkedList S[] = new LinkedList[27];

for (int i=0;i<27;i++)

S[i]=new LinkedList();

(2pts) Write a method that returns the total number of occurrences of the same value v in S.

int occurrences ( LinkedList S[], int v)

// v is the searched value, S is the array of lists

{

}

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!