Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Data Structure Using C++ (Queue) C++ code (NOT JAVA C++ JUST)

C++ PROGRAMMING LANGUAGE PLEASE ::

We can use a queue to simulate the flow of customers through a check-out line in a store. In this simulation we will have the following details:

  • one check-out line
  • the expected service time for each customer is one minute (However, they may have to wait in line before being serviced)
  • between zero and two customers join the line every minute

We can simulate the flow of customers through the line during a time period n minutes long using the following algorithm:

Initialize the queue to empty.

for ( minute = 0 ; minute < n ; ++minute )

{

      if the queue is not empty, then remove the customer at the front of the queue.

      Compute a random number k between 0 and 3.

      If k is 1, then add one customer to the line.

      If k is 2, then add two customers to the line.

      Otherwise (if k is 0 or 3), do not add any customers to the line.

}

In addition, the algorithm will keep track of the following:

  • the total number of customers served
  • the combined total wait time of all customers
  • the maximum length of time any of these customers spent waiting in line

Operations on the Queue for the Check-out Line Simulation

Given a time of 5 minutes, the following demonstrates the operations on the queue: 

use 1.png 

this is for test the program :: 

use 2.png

nd you can use these thing ::::

struct node { int data; node *next; node(int d,node *n=0) { data=d; next=n; } }; class stack { node *topp; public: stack(); void push(int el); bool pop(); int top(); bool top(int &el); //~stack(); //void operator=(stack &o); //stack(stack &o); }; stack::stack() { topp=0; } void stack::push(int el) { topp=new node(el,topp); } bool stack::pop() { if(topp==0) return false; node *t=topp; topp=topp->next; delete t; return true; } int stack::top() { if(topp!=0) return topp->data; } bool stack::top(int &el) { if(topp==0) return false; el=topp->data; return true; }

please need a full code without any errors

Test Plan for "Check-out Line" Simulation Program
Total Number of
Time (minutes)
Average Wait Longest Wait
Customers Served
30
60
120
480
expand button
Transcribed Image Text:Test Plan for "Check-out Line" Simulation Program Total Number of Time (minutes) Average Wait Longest Wait Customers Served 30 60 120 480
minute
queue operations
corresponding diagram
isempty?
yes
no degueue (empty queue)
1 engueue(0)
1
no
degueue
2 engueue(1)
engueue(1)
2
no
1
degueue
1
2 engueue(2)
engueue(2)
1
2
2
no
1
2
2 H2 .
degueue
1 engueue(3)
2 H 2
3
4
no
2
2
degueue
3
O no engueue (k=0)
2
3
expand button
Transcribed Image Text:minute queue operations corresponding diagram isempty? yes no degueue (empty queue) 1 engueue(0) 1 no degueue 2 engueue(1) engueue(1) 2 no 1 degueue 1 2 engueue(2) engueue(2) 1 2 2 no 1 2 2 H2 . degueue 1 engueue(3) 2 H 2 3 4 no 2 2 degueue 3 O no engueue (k=0) 2 3
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education