Data Structures and Algorithms Prof. Ajit A. Diwan Prof. Ganesh Ramakrishnan Prof. Deepak B. Phatak Department of Computer Science and Engineering IIT Bombay Session: Mumbai Vada-Pav Restaurant Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Mumbai Vada-Pav Restaurant: Overview This restaurant has Fixed food items in the menu One counter (queue) for customer to place order Every customer can place order for Maximum 10 items Quantity must be specified for each item Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Customer Arrives and stands in a queue Places order on his/her turn Gets a Token ID and cost to be paid Waits at a table to collect the order when it is ready Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Data Structures Restaurant maintains information of each item in the menu Food ID (e.g. 1) Food Name (e.g. Samosa) Rate per item (e.g. Rs. 15.0) We will use structure ‘foodInfo’ to maintain this information Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Data Structures Structure: foodInfo Food ID Food Name Rate 1 Vada Pav 10.0 2 Uttappa 18.0 3 Samosa 15.0 … 12 Shira 26.0 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Data Structures using Queues Use queues to facilitate the process Queue 1: Customer Queue Places order by giving (multiple) Food ID and Quantity Gets Token ID Cost to be paid Queue 2: Order Dispatch Queue Token ID (The order is ready to be collected by the customer) Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Data Structure for the kitchen Each order placed by a customer is sent to kitchen Kitchen will prepare the ordered items different time needed to prepare an order Orders may not be prepared in their arrival sequence For now, we use a simple array to represent kitchen operations Each element of the array will have Token-id Time for preparation We will store every element of order queue in this array For now, we will allocate an arbitrary time for order preparation Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Let us demonstrate the entire process Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration CustomerOrder Queue Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration CustomerOrder Queue Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration CustomerOrder Queue Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration CustomerOrder Queue Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration CustomerOrder Queue Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Order placed Token: 1001 Preparation started in kitchen foodID Qty 3 1 7 5 Token: 1001 Cost: 165 CustomerOrder Queue Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Order placed Token: 1002 Preparation started in the kitchen foodID Qty 1 3 9 2 12 1 Token: 1002 Total Cost: 100 CustomerOrder Queue T 1001 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Order placed Token: 1003 Preparation started in the kitchen foodID Qty 11 1 Token: 1003 Total Cost: 19 CustomerOrder Queue T 1002 T 1001 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Order placed Token: 1004 Preparation started in the kitchen foodID Qty 5 2 Token: 1004 Total Cost: 40 CustomerOrder Queue T 1002 T 1001 T 1003 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Items are being prepared in the kitchen CustomerOrder Queue T 1004 T 1002 T 1001 T 1003 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Kitchen OrderDispatch Queue CustomerOrder Queue 1001 T 1004 T 1002 T 1001 T 1003 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Kitchen OrderDispatch Queue CustomerOrder Queue 1003 1001 CustomerOrder Queue T 1004 T 1002 T 1001 T 1003 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Kitchen OrderDispatch Queue CustomerOrder Queue 1003 1002 1003 1001 CustomerOrder Queue T 1004 T 1002 T 1001 T 1003 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Demonstration Kitchen OrderDispatch Queue CustomerOrder Queue 1004 1002 1003 1001 CustomerOrder Queue T 1004 T 1002 T 1001 T 1003 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
References All images are taken from https://openclipart.org Which are released in public domain Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay
Thank you Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay