Question: Consider your ID as an array of 9 elements. Example ID: 201710340 arr 2 0 1 7 1 0 3 4 0 Consider a Circular

Consider your ID as an array of 9 elements. Example ID: 201710340

arr

2

0

1

7

1

0

3

4

0

Consider a Circular Queue implemented using an array of length 6. Show the contents of the queue after executing each of the following segments of code in order.

  1. q.enqueue(arr[0]);

q.enqueue(arr[1]);

q.enqueue(arr[2]);

q.enqueue(arr[3]);

q

  1. q.dequeue();

q.dequeue();

q

  1. q.enqueue(arr[4]);

q.enqueue(arr[5]);

q.enqueue(arr[6]);

q

  1. What is the output of the following statements?

System.out.println(q.size());

System.out.println(q.first());

  1. Explain what will happen after after executing the following statements.

q.enqueue(arr[7]);

q.enqueue(arr[8]);

q

  1. What is the performance (in Big-O notation) of each of the previous methods? Explain.

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!