 Welcome to this course on data structures and algorithms. Last time, we saw the basics of implementing Q using standard template library. In this session, we will take a simple example of a bus queue and try to understand how the queues are formed and what is the important information about bus queues that we need to find out. First, let us do a quick overview of a bus queue. People will arrive and stand in a queue at the bus stop. They will wait for the bus to arrive. Please note that in actual practice, people will arrive at random times. Similarly, buses will arrive at around the scheduled time, not necessarily exactly at the scheduled time. So, again there is some randomness involved. In this particular illustration, we are not going to use any random number generator, etcetera to simulate the actual bus queue. We are just trying to illustrate how bus queues are handled in a C++ program. So, to recapitulate, people will arrive and stand in a queue at the bus stop. We will note an arbitrary time of arrival of each person. Similarly, buses will arrive at the scheduled time or around it. There will be limited available seats in every bus. Again, we will arbitrarily assign the number of seats available in any bus or the actual bus arrival time. The most important thing about bus queues in which both the bus company and the passengers are interested is how long a passenger has to wait in a queue to get a bus. So, we define the waiting time of a person as time of boarding the bus minus arrival time of person at the bus stop. Of course, if we do these calculations over a long period, accounting for a large number of people arriving and boarding, etcetera, we will be able to find out the average waiting time in the bus queue. So, let us demonstrate this entire process of people standing in a bus queue. Here is a sample bus stop. People will come and the buses will come from this side. So, here is the first person who comes in. We arbitrarily assign a tag to that person say 1001 and arbitrarily assign an arrival time. Let us say 1450. Please note that in real life, when we simulate a bus queue, we will have to generate this number randomly. We shall speak about it in a practice problem later. Here is another person who comes in. Let us assume that he arrives at 14 hours 19 minutes. Here is a third person arrives at 1421. Note that we are giving an arbitrary increasing tag to each person who arrives at the queue. Here is the fourth person and here is the fifth person. Note that so far no bus has come. All of them are waiting for bus to arrive. Next comes a bus. This arrives at 1430 again an arbitrary time. Let us again arbitrarily assume that there are only two available seats in this bus. So, what will happen? Only the first two people in the queue will be able to board the bus. This is depicted here. When the first two people board the bus, we will have to remove them from the queue and we have to remember for later usage for how long did they wait. This person arrived at 1415. The bus arrived at 1430. So, he waited for 15 minutes. The next person similarly waited for 11 minutes. Next another bus comes. All the three people are waiting for the next bus to arrive and let us assume that this bus arrives at 1440. Let us assume that there are seven available seats in this bus. Of course, there are only three people remaining in the queue. All three of them will be able to board the bus. Once again we calculate the actual waiting time for each person individually. Now we know when bus arrived and we know when the people arrived. So, the difference between these two will be the waiting time. In a nutshell, we have simulated a queue, giving of course, arbitrary arrival times for both the bus and the passengers, arbitrary number of seats available in the bus, etcetera. But we are able to calculate the waiting time for each person and consequently the average waiting time. So, in our example with assumed hypothetical timings, we have person one waited for 15 minutes, person two for 11 minutes and so on. Totally five persons waited for a sum of 76 minutes. The average wait time is thus 15.06 minutes. In practice, in real life, these are the timings which are most important which will permit the bus company to schedule more buses during peak hours. For example, or for people to estimate at what time they should appear at the bus stop so that they are more likely to get a bus. So, what we note in this example is that although we will be illustrating programming of a bus queue using these arbitrary numbers which are illustrated in this example, in actual practice passengers will arrive randomly. Buses will also arrive randomly. They may arrive around their schedule time, but there will be some random. And finally, even the number of available seats will have to be generated randomly. In one of the practice problems, we will illustrate how the random number generator function of C plus plus can be utilized to simulate this. These are some of the references. First of all, all images which are used in this particular slide deck are from openclipper.org. Those of you are interested can look at it and will note that all images available are under creative commons license and therefore, they can be freely used. These are all released in public domain. To conclude, in this session, we have taken our discussion in the queues further and we have illustrated a practical problem, namely people waiting for a bus in a queue. We have demonstrated using arbitrary numbers to represent the arrival time of people and arrival time of the bus, etcetera, to demonstrate that we can actually calculate the waiting time for each person and the average waiting time for that particular bus stop when people arrive. Later on, as I said in a practice problem, you will look at the random numbers to be generated to represent arrival times, etcetera. But in the next session, we will simply look at a C plus plus program which implements this particular illustration of the bus queue. Thank you.