Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structures and Algorithms

Similar presentations


Presentation on theme: "Data Structures and Algorithms"— Presentation transcript:

1 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

2 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

3 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

4 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

5 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

6 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

7 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

8 Let us demonstrate the entire process
Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

9 Demonstration CustomerOrder Queue
Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

10 Demonstration CustomerOrder Queue
Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

11 Demonstration CustomerOrder Queue
Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

12 Demonstration CustomerOrder Queue
Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

13 Demonstration CustomerOrder Queue
Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

14 Demonstration Order placed Token: 1001 Preparation started in kitchen
foodID Qty Token: 1001 Cost: 165 CustomerOrder Queue Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

15 Demonstration Order placed Token: 1002
Preparation started in the kitchen foodID Qty Token: 1002 Total Cost: 100 CustomerOrder Queue T 1001 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

16 Demonstration Order placed Token: 1003
Preparation started in the kitchen foodID Qty Token: 1003 Total Cost: 19 CustomerOrder Queue T 1002 T 1001 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

17 Demonstration Order placed Token: 1004
Preparation started in the kitchen foodID Qty Token: 1004 Total Cost: 40 CustomerOrder Queue T 1002 T 1001 T 1003 Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay

18 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

19 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

20 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

21 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

22 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

23 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

24 Thank you Ajit A. Diwan, Ganesh Ramakrishnan, and Deepak B. Phatak, IIT Bombay


Download ppt "Data Structures and Algorithms"

Similar presentations


Ads by Google