Question: Simple Java Problem 1 - Queue A queue is a useful structure in computer problems. The queue is often referred to as FIFO (First In

Simple Java

Simple Java Problem 1 - Queue A queue is a useful structure

Problem 1 - Queue A queue is a useful structure in computer problems. The queue is often referred to as FIFO (First In First Out). Some useful queue methods are sizeof(how many items are in the queue), enqueue (put a new item in the queue at the end), dequeue (remove the first item from the queue and return the item), isEmpty (true if there are no items in a queue). For this part of the exam, you will implement these 4 methods for use on an array that will act as a queue. (Look to part 4 for the ways that your methods will be used). NOTE: For your solution, you should keep the size of the queue or stack as a value in the array. As you add to or remove from the queue or stack, you should update this value appropriately. Part 1 - Identify Subproblems (3 points) Identify at least 3 subproblems for the problem you chose. 1. 2. 3. Part 2 - Make a Plan (5 points) Make a plan for how you will solve this problem (and sub-problems) using any combination of writing, pseudocode, or flowchart. Part 3 - Java Code (5 points) Write the Java code for implementing your solution to this problem. Part 4 - Example (5 points) Problem 1 Shown below is a possible way that your methods may be used. Show the value of queue and output. 1 int[] queue = new int[10); 2 enqueue (queue, 3); 3 enqueue(queue, 6); 4 enqueue (queue, 4); 5 System.out.println(sizeof(queue)); 6 while(!isEmpty(queue)) System.out.println(dequeue (queue)); Alter line queue is: This is output 1 2 3 4 S 7 (first time) 7(second time) 7 (third time) 7 Problem 2 Shown below is a possible way that your methods may be used. Show the value of stack and output 1 int[] stack - new int[10]; 2 push(stack, 3); 3 push(stack, 6); 4 push(stack, 4); 5 System.out.println(sizeof(stack)); 6 while(lisEmpty(stack)) 7 System.out.println(pop(stack)); After line stack is: This is output 1 2 3 4 5 7 (first time) 7 (second time) 7 (third time) |

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!