CSE 214 Final: Study Guide: Simplified Queues (ARRAY IMPLEMENTATION)

246 views3 pages

Document Summary

A sequence of data elements arranged one after another conceptually. An element can only be added to the rear end of the queue . (enqueue) An element can only be removed from the top of the queue . (dequeue). Operating systems - input buffers, print queues, process scheduling. Telecommunications and transportation engineering - modeling and simulation of computer and phone networks, road systems and transportation hubs. Class public class intqueue implements cloneable { public final int capacity = 100; private int[] data; private int front; private int rear; Constructor public intqueue() { front = -1; rear = -1; data = new int[capacity]; isempty() method. Checks if the queue is empty or not based on the value of front. (-1 means it is empty). public boolean isempty() Enqueue() public void enqueue(int item) { if ((rear+1)%capacity == front) throw new fullqueueexception(); if (front == -1) { front = 0; rear = 0; else rear = (rear+1)%capacity; data[rear] = item;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers