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.
- q.enqueue(arr[0]);
q.enqueue(arr[1]);
q.enqueue(arr[2]);
q.enqueue(arr[3]);
| q |
|
|
|
|
|
|
- q.dequeue();
q.dequeue();
| q |
|
|
|
|
|
|
- q.enqueue(arr[4]);
q.enqueue(arr[5]);
q.enqueue(arr[6]);
| q |
|
|
|
|
|
|
- What is the output of the following statements?
System.out.println(q.size());
System.out.println(q.first());
- Explain what will happen after after executing the following statements.
q.enqueue(arr[7]);
q.enqueue(arr[8]);
| q |
|
|
|
|
|
|
- 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
Get step-by-step solutions from verified subject matter experts
