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
  • Satisfactory Essays

    NT1230 Lab 10

    • 1546 Words
    • 8 Pages

    6. In the Instances of selected object list, select 0, and then click Add. The Queue Length counter appears in the Added counters list.…

    • 1546 Words
    • 8 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
  • 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

    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
  • 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
  • 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
  • Powerful Essays

    Bca Cs-63

    • 1608 Words
    • 7 Pages

    Consider the following set of processes that arrive in the ready queue at the same time:…

    • 1608 Words
    • 7 Pages
    Powerful 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
  • Powerful Essays

    The mathematical theory of waiting lines (or queues) has received a great deal of attention from academic researchers and their results and insights have been successfully applied in a variety of settings. (2) However, most of this work is concerned with the objective reality of various 'queue management ' techniques: for example, what the effects are upon average waiting times of adding servers, altering 'queue discipline ' (the order in which customers are served), speeding up serving times, and so on. What has been relatively neglected, however, is much substantive discussion of the experience of waiting.…

    • 4635 Words
    • 19 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
  • 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