CS301-Lec10 handout

# CS301-Lec10 handout - CS301 Data Structures Lecture No 10...

This preview shows pages 1–3. Sign up to view the full content.

CS301 – Data Structures Lecture No. 10 ___________________________________________________________________ Data Structures Lecture No. 10 Reading Material Data Structures and Algorithm Analysis in C++ Chapter. 3, 6 3.4.3, 6.1 Summary 1) Queues 2) Simulation Models 3) Priority Queue 4) Code of the Bank simulation Queues In the previous lecture, we discussed the queue data structure and demonstrated its implementation by using array and link list. We also witnessed the usefulness of queue as data structure in the simulation example. This concept can be further elaborated with a daily life example relating to banking sector. Suppose, customers want to deposit or withdraw money from a bank, having four cashiers or tellers. The teller helps you in depositing the money or withdrawing the money from the same window. This window is known as teller window. The customer needs some service from the bank like depositing the money, bill etc. This transaction needs some time that may be few minutes. A person enters the bank and goes to the teller who is free and requests him to do the job. After the completion of the transaction, the person goes out of the bank. Now we will discuss a scenario when there is a lot of rush of customers. The tellers are just four. Now the tellers are busy and the new customers will form a queue. In this example, we need a queue in front of each of the tellers. A new customer enters the bank and analyzes the four queues and wants to join the shortest queue. This person has to wait for the persons in front of him to be served. Another person may come behind him. In this simulation, we will restrict the person from changing the queue. A person comes into the bank at 10 O clock. His transaction time is 5 minutes. He has to wait for another fifteen minutes in the queue. After this, the teller serves him in 5 min. This person comes at 10 am and waits for fifteen minutes. As the transaction time is 5 minutes, so he will leave the bank at 1020. Now this is the situation of simulation and we have to write a program for this. We can go to some bank and analyze this situation and calculate the time. At the end of the day, we can calculate the average time for each of the customer. This time can be 30 minutes. Here we will simulate this situation with the help of a computer program. This is the real life example. Let’s see the picture of simulations to understand what is happening in the bank. In the picture below, we have four tellers and four queues, one for each of the tellers. Each teller is serving a customer. When the transaction of a customer is completed, he will leave the bank. Page 1 of 11

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS301 – Data Structures Lecture No. 10 ___________________________________________________________________ A person enters the bank. He sees that all the four tellers are busy and in each queue there are two persons waiting for their turn. This person chooses the queue no. 3. Another person enters the bank. He analyzed all the queues. The queue no 3 is the
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/21/2010 for the course CS CS301 taught by Professor Dr.naveed malik during the Spring '10 term at Virtual University of Pakistan.

### Page1 / 11

CS301-Lec10 handout - CS301 Data Structures Lecture No 10...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online