Question: Problem 1: On slide #16 entitled Circular Array Queue Data Structure (AS #2) are two methods, enqueue and dequeue. This slide is reproduced below. Initial

Problem 1: On slide #16 entitled "Circular Array Queue Data Structure (AS #2) are two methods, enqueue and dequeue. This slide is reproduced below. Initial State of Circular Array Queue Data Structure (AS #2) 0 5 o 23 0 16-512 100244 18 33 6 size 0 front back size - 1 caer Front + Back 17 Basic idea only! What if queue is empty? void enqueue (char x) what if Q is empty/full? . Enqueue? Qlback] - x Dequeue? back - (back.1) .length: What if array is full? How to test for empty? / Basie idea only! . What is the complexity void degueue (char x) what if Q is empty? of the operations? char x - Qfront); . Can you find the kth Tront - (front: 1 $ 0.length: element in the queue? return x; Your enqueue method (25 points) CT- DAN Your dequeue method (25 points) Your task: Develop enqueue and dequeue methods using a circular array queue. Record your algorithms using the space provided on the next page. The algorithms must use correct Java syntax. You might want to develop the methods in the Eclipse IDE to ensure correct syntax but this is NOT required. Use the specifications below for your methods. 1. Assume an integer array named "*" has been already been created. The initial size of the array is 10. Use a variable "size" to track the number of elements in "s". 2. If the array becomes full, use a method called "resize" to double the size of the array and proceed with the enqueue operation. You may assume a "resize" method exists but you must supply the doubled size as an argument to resize. You do NOT have to develop the resize method. 3. If the array is empty when the dequeue method is invoked, throw an exception named "NoSuchElementException" 4. Previous enqueue and dequeue operations have already occurred. The current values in the 's array are shown on the next page. 5. After developing your methods, record the state of the ""in the array provided after the following operations are performed. Be sure to include the values in the array, the location of front and back, and size. a. enqueue(2) b. dequeue c. enqueue(21) d. enqueue(3) e enqueue(5) fenqueue(-4) dequeue Final State of (10 Points) 0 front back size=
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
