Preview

Jvjk

Satisfactory Essays
Open Document
Open Document
305 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Jvjk
ADT Queues

ADT Queues Definition:

Queues are ordered lists, which follow a FirstIn-First-Out (FIFO) order. These can be implemented as an array or using a dynamic memory allocation scheme. Queues are usually implemented using a circular array. The first element is known as the head and the last element is known as the tail.

Operations: 1. Enqueue

2. Dequeue 3. FullQ 4. Makenull
5. EmptyQ

1. Enqueue

{ if (NumItems == MaxQueue) Success = False; //queue is full else { Rear = (Rear + 1) % MaxQueue; //increment rear Q[Rear] = El; NumItems = NumItems + 1; Success = True; }

}

2. Dequeue { if (NumItems == 0) Success = False; //queue is empty else { //Remove the element at the front of the queue El = Q[Front]; Front = (Front + 1) % MaxQueue; //increment Front NumItems = NumItems - 1; Success = True; } }

3. Makenull {

NumItems = 0; Front = 0; Rear = MaxQueue - 1;
}

4. FullQ { return (NumItems == MaxQueue); } 5. EmptyQ { return (NumItems == 0); }

Queues- Example
• Print Jobs - All requests from workstations are enqueued to the print queue on a first come first served basis - The current (first) printjob is dequeued and sent to the printer for processing

Queue - Applications
• I/O Request Handling File server - Workstation (print, data access,etc.) • Telephone Call Handling • History functions in applications

Enqueue public class ArrayQueue implements Queue { // ... public void enqueue( Object o ) { if ( (rear + 1) % MAX != front ) { store[rear] = o; rear = (rear + 1) % MAX; } } // ... }

Dequeue public class ArrayQueue implements Queue { // ... public Object dequeue() throws Exception { if ( empty() ) { throw new Exception(); } else { Object data = store[front]; store[front] = null; front = (front + 1) % MAX; return data; } } }

Using the Queue
Queue q = new ArrayQueue(); int result; // the following should be enclosed in a try-catch stmt q.enqueue( new Integer(5) ); q.enqueue( new Integer(2) ); result = ((Integer)q.dequeue()).intValue();

You May Also Find These Documents Helpful

  • Good Essays

    Nt1330 Unit 9 Final Paper

    • 1263 Words
    • 6 Pages

    Assuming 5 MDs on duty at an average (each with a service rate of 3.1 patients per hour) and that all patients (143 per day) see an MD, calculate the effect of a 4% increase in the arrival rate on the expected wait time in queue: Wq (use Queuing Formulas, assume uniform arrival across 10 working hours per day, note that it’s a multiple server system drawing from a single line – M/M/S). Comment on this…

    • 1263 Words
    • 6 Pages
    Good Essays
  • Powerful Essays

    1. The Quality of Service (QoS) is the fraction of calls whose waiting time in queue is no…

    • 958 Words
    • 4 Pages
    Powerful Essays
  • Satisfactory Essays

    2) Refer to the information above. What is the maximum inventory held in a given EOQ cycle?…

    • 1687 Words
    • 12 Pages
    Satisfactory Essays
  • Powerful Essays

    Simul8 Report

    • 1272 Words
    • 6 Pages

    Figure 1 depicts the model used for the simulation, where the two types of calls enter the system through the two entry points - type 1 and type 2. They are then sorted and routed out to their respective queues through labels named ‘type’. Type 1 customers are served by either agent 1 or agent 3 (generalist), depending on availability. Similarly, type 2 customers are served by agent 2 or agent 3, after which the customers leave the system by their respective exit points.…

    • 1272 Words
    • 6 Pages
    Powerful Essays
  • Satisfactory Essays

    Child development early stages through ages 12, By Celia Decker. children/ toddlers are between ages of one and three years old. As toddlers develop physically their body start to mature. All the others don't grow as quickly as infants they go through many important physical changes. Toddlers grow at different rates. Toddler go through certain stages such as, the physical development intellectual development, and social emotional development, and there are certain ways to care for toddlers.…

    • 364 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    On the other hand, we reviewed the utilization, queue size for each machine, checked the revenue, completed jobs and lead time data. We noticed that on Day 40, Day42, and Day 44, machine in station 1 has the utilization more than 90% which means station 1 is a bottleneck. After identifying the bottleneck, We decided to purchase machine in station 1 first on Day 51 to see how this modification action would affect the factory operation.…

    • 1533 Words
    • 7 Pages
    Powerful Essays
  • Good Essays

    Mcdonalds vs Wendys

    • 944 Words
    • 4 Pages

    In a world that is full of low fat low-carbohydrate diets and compulsive daily exercise, people seem to be more conscientious with their choices of foods they consume; but the twenty- first century demands convenience where fast food restaurants incorporates ones needs for quick, easy, and , inexpensive food. Sadly, the majority of this type of food can be a very unhealthy food choice. Fast food restaurants typically offer high fat processed foods. In defense to this stereotype, two of the most popular fast food restaurants, Wendy’s and McDonald’s, are now offering choices low in carbohydrates and saturated fats on their menu without taking away the convenience and taste. Both of these restaurants fall under the category of fast food, yet they both carry distinctive quality in their healthy menu items, Although the difference in characteristics of their healthy choices, both Wendy’s and McDonald’s offer a variety of salads their healthy food menu.…

    • 944 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    A rope divider is used at all times that guides customers to the order point. I visit Chipotle on a regular basis during peak times and I find the system adequate in moving customers through the process. Employees appear well trained in preparing the selections quickly without error. A sign should be placed to direct the pick-up of phone, fax, or I-Phone orders.…

    • 1881 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Littlefield Overview

    • 485 Words
    • 2 Pages

    receivers in an order are completed, the order is shipped immediately. A job is not shipped to its…

    • 485 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Firstly, we examined our demand and completed job counts to check our productive capacity and inventory. It demonstrated that we were producing faster than our capacity and market had increasing level. Therefore; we decided to change our reorder quantity and reorder point in order to produce more at the same time and meet the demand.…

    • 441 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Data Structure

    • 328 Words
    • 2 Pages

    You need to create a Loop instruction that executes once for each item in the array.…

    • 328 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Our waiting area is equipped with an electronic queuing system to make transaction more convenient…

    • 1455 Words
    • 5 Pages
    Good Essays
  • Powerful Essays

    Round Robin

    • 2242 Words
    • 9 Pages

    It is one of the oldest, simplest, fairest and most widely used scheduling algorithms, designed especially for time-sharing systems. A small unit of time, called time slice or quantum, is defined. All runnable processes are kept in a circular queue. The CPU scheduler goes around this queue, allocating the CPU to each process for a time interval of one quantum. New processes are added to the tail of the queue.…

    • 2242 Words
    • 9 Pages
    Powerful Essays
  • Powerful Essays

    9 History − System structure − User perspective − Operating system services − Assumptions about hardware − Introduction to the kernel − Architecture of the UNIX operating system − Introduction to system concepts − Kernel data structures – System administration − Summary and preview. UNIT II BUFFER CACHE 9 Buffer headers − Structure of the buffer pool − Advantages and disadvantages of the buffer cache − Internal representation of files − Inodes − Structure of a regular file − Directories − Conversion of a path name to an inode − Super block − Other file types. UNIT III SYSTEM CALLS FOR FILE SYSTEM 9 Open − Read − Write − File and record locking − Adjusting the position of file I/O − LSEEK − Close − File creation − Creation of special files − Pipes − Dup – Mounting and unmounting file systems. UNIT IV THE STRUCTURE OF PROCESSES 9 Process states and transitions − Layout of system memory − The context of a process − Saving the context of a process − Process control − Process creation − Signals − Process termination − Awaiting process termination − Invoking other programs – The shell − System boot and the INIT process. UNIT V PROCESS SCHEDULING AND MEMORY MANAGEMENT POLICIES 9 Process scheduling − Memory management policies − Swapping − A hybrid system with swapping and demand paging − The I/O subsystem − Driver interfaces – Disk drivers − Terminal drivers. Total: 45 TEXT BOOK 1. Maurice J. Bach, “The Design of the Unix Operating System”, PHI, 2004. REFERENCE 1. Vahalia, “Unix Internals: The New…

    • 53108 Words
    • 213 Pages
    Powerful Essays
  • Satisfactory Essays

    Neha

    • 283 Words
    • 2 Pages

    Operation Research Code: IT504D Contact: 3L + 1T Credits: 4 Module I Linear Programming Problems (LPP): Basic LPP and Applications; Various Components of LP Problem Formulation. Solution of Linear Programming Problems: Solution of LPP: Using Simultaneous Equations and Graphical Method; Definitions: Feasible Solution, Basic and non-basic Variables, Basic Feasible Solution, Degenerate and Nondegenerate Solution, Convex set and explanation with examples. [5L] Solution of LPP by Simplex Method; Charnes’ Big-M Method; Duality Theory. Transportation Problems and Assignment Problems. [12L] Module II Network Analysis: Shortest Path: Floyd Algorithm; Maximal Flow Problem (Ford-Fulkerson); PERT-CPM (Cost Analysis, Crashing, Resource Allocation excluded). [6L] Inventory Control: Introduction to EOQ Models of Deterministic and Probabilistic ; Safety Stock; Buffer Stock. [3L] Module III Game Theory: Introduction; 2-Person Zero-sum Game; Saddle Point; Mini-Max and Maxi-Min Theorems (statement only) and problems; Games without Saddle Point; Graphical Method; Principle of Dominance. [5L] Module IV Queuing Theory: Introduction; Basic Definitions and Notations; Axiomatic Derivation of the Arrival & Departure (Poisson Queue). Poisson Queue Models: (M/M/1): (∞ / FIFO) and (M/M/1: N / FIFO) and problems. [5L] Text Books: 1. H. A. Taha, “Operations Research”, Pearson 2. P. M. Karak – “Linear Programming and Theory of Games”, ABS Publishing House 3. Ghosh and Chakraborty, “Linear Programming and Theory of Games”, Central Book Agency 4. Ravindran, Philips and Solberg - “Operations Research”, WILEY INDIA References:…

    • 283 Words
    • 2 Pages
    Satisfactory Essays

Related Topics