Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FIFO Queue using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Queue_Array { public class AFIFOQueue { public int[] arr; public int front, rear; public

image text in transcribedimage text in transcribedFIFO Queue using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Queue_Array { public class AFIFOQueue { public int[] arr; public int front, rear; public int size; public AFIFOQueue(int Size) { arr = new int[Size]; size = Size; front = -1; rear = -1; } public bool Empty() { if (rear == -1) return true; else return false; } public bool Full() { if (rear == front - 1 || front == 0 && rear == size - 1) return true; else return false; } public void Enqueue(int x) { if (!Full()) { if (rear == -1) //empty queue { front = 0; rear = 0; } else { if (rear != size - 1) //rear not reach the last index rear = rear + 1; else rear = 0; //rear reach the last index, must jump to the first (circular queue) } arr[rear] = x; } else Console.WriteLine("The queue is full!"); } public int Dequeue() { if (!Empty()) { int x = arr[front]; if (front != rear) //more than one elements in the queue { if (front != size - 1) //regular case front = front + 1; else //front is at the end of the array, move it to the first (circular queue) front = 0; // } else //front = rear, only one element in the queue { front = -1; //after delete it becomes empty queue rear = -1; } return x; } else { Console.WriteLine("The queue is empty!"); return -1; } } public void Print() { if (rear == -1) Console.WriteLine("The queue is empty!"); else if (rear >= front) for (int i = front; i   Implement FIFO queue of integers using a double linked list as its underlying physical data structure. Note that double linked list implementation can be found in the following. The program must contain the following 2 operations: enqueue and dequeue. Your Main method should test your FIFO queue class. (Note, do not include double linked list methods that will not be used by your FIFO queue class class)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions