Question: To solve this problem use stack and NOT Queue : You are in a bank that has two tellers, teller A and teller B. Customers,
To solve this problem use stack and NOT Queue :
You are in a bank that has two tellers, teller A and teller B. Customers, each assigned some special number, line up in a single queue to await their turn to be served by the next available teller. You can assume that no other customers arrive during this problem.
When a teller is ready to serve a customer, they say TELLER A READY or TELLER B READY and the next customer in the queue immediately goes to that teller.
When a teller has completed assisting a customer, they say CUSTOMER N DONE (for example CUSTOMER 10 DONE, meaning the teller has finished helping customer 10) and then follow that immediately by saying TELLER A READY or TELLER B READY.
Assume there is a device at the head of the queue that says NO MORE CUSTOMERS when there are no more customers in the queue.
Write an algorithm that continues to run until it receives a NO MORE CUSTOMERS signal. After it receives the signal, your algorithm should stop and should then print two things: first, the number of customers served; second, a list of the customer numbers in the order in which they were done being served.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
