 Hello, and welcome to next lecture that is on priority queues and DQ that is double ended queue. So these are the learning outcomes. At end of this session, students will be able to explain priority queue and DQ queue in the data structure. So let us start with the priority queue. What does it mean by priority? So you know what is the meaning of a priority in general. So we have to give some priority at the sometime at the stage of the life. So in that, so we do the things which are more prior to the next thing. In the same manner, if you want to implement the priority queue in the data structure, there are some of the conditions we have to see. Let us see where the priority queue is first seen. So the priority queue are useful in the data structures in simulations, particularly for maintaining the sets of future events. Order by the time that we can quickly let you what are the next things to happen. They are called priority queues because they are enabled to retrieve the items, neither by the insertion time nor by a key match, but by which the item has highest priority of retrieval. So these are the priority queue operations supported. So we have seen the operations in the linear queue and the circular queue. So queue follows the first in first out linear data structure in which the items are added from the rare end and deleted from the front end. So where we do N queue and D queue operations. So while N queueing we see the overflow condition and for the D queue we can see the underflow condition. In the similar manner, the priority queue supports the following operations. First, that is an underflow conditions like this. So is an empty. If the function is empty called, it is used to check whether the queue has no elements. Means if you try to delete the element from the queue, when there are no elements, we have to see that that is an empty. Next, we are going to see that next operation that is insert with priority. Now the priority is given while inserting. Add an element to the queue with an associate priority. So there are two types of priority that is ascending and descending that we are going to see in next. So third operation is what the pull highest priority element means we are going to remove the elements from the queue which has the highest priority and returned it. We are not going to see that that is first in first out. For example, in the live scenario, if the person comes with a injured in a hospital, so the doctor has to attend it first based on the priority given to the injured person. Otherwise, he will be more injured if he is not attended on the priority basis. So the doctor stops all the things and attend to the injured person. So that is known as an priority queue. So that was the most live example while using an priority queue. So in the similar manner, the priority queues are used in the job scheduling in the CPU, CPU scheduling, all these things. So there are two types of priority queues. We are going to see that is an ascending priority queue and descending priority queue. So based on this, the highest priority element that is pull means we are going to remove the element from the queue that has an highest priority. So in ascending priority, we are going to remove the smallest element in the queue. That's why it is known as an ascending priority queue. In the same manner, if you are going to remove the largest element in the queue, that is we are going to dequeue operation. So that is known as an descending priority queue. So in short, we are going to see that the priority queue supports three operations. That is is empty, insert with priority and pull highest priority element. So these are the two types of priority that is ascending priority queue and descending priority queue. Now you tell me what are the advantages of priority queue? So it is easy to implement and process with the different priority can be efficiently handled. So now let us start with the double-ended dequeue. Dequeue is also a homogeneous list of elements in which the insertion and deletion operations are performed from both the ends. As in the normal linear queue and the circular queue, we have seen that the insertion and the deletions can be done from only one end. That is rare and the front end. But in double-ended dequeue, in which we are going to insert and delete operations are performed from both the ends. That we can insert the element from the rare end or the from the front end. Hence it is known as a double-ended queue and it is commonly referred as a double-ended queue. So now let us see the types of dequeue. As there are two types of dequeue that is input restricted dequeue and output restricted dequeue. As shown in this figure, the input, why it is known as an input restricted dequeue? As the insertion is allowed from one end that is a rare end and the deletions can be done from both the ends. That is from the front end as well as from the rare end. So that is why it is known as an input restricted dequeue. Now next that is the output restricted dequeue means what? So here the deletion is allowed only at once. That is from the rare end. So the insertion can be done from both the ends. So when you are going to delete the items from only one end that is known as an output restricted dequeue. When you are going to delete from both the ends that is known as an input restricted dequeue. Only the insertion can be allowed from the one end. So now based on the both insertion and deletions are performed from the either end it is necessary to design an algorithm to perform the following four operations. That is the insertion of an element at the rare end of the queue. The deletion of the element from the front end of the queue. Next is the insertion of an element from the front end of the queue. Deletion of an element from the rare end of the queue. That's what we have seen in the previous figure. That is insertion of the element can be done from the rare end and the deletion can be done from both the ends. That is the rare end front end. And the next is the insertion of the element is from the front end of the queue and the deletion can be done from both the ends. Either next the deletion can be done from the rare end of the queue and the insertion can be done from both the ends. So that is known as the double ended dequeue. So, now we will see one by one, what are the applications of an queue. So we have seen the live examples of an priority queue like in hospitals where the priority queue is used. So, in the same manner the queues are used in the various applications in the data structures such as in job scheduling, disk scheduling and the simulation. So when the resources is shared among the multiple consumer means what? So when the printer that is connected in the network that is a network printer it is called as a network printer means in a lab there are 40 to 50 machines are there and the printer is shared among all the 50 machines and the CPU scheduling or the disk scheduling is what? So whenever the persons are going to give the print from each and every machine of the in the lab so they have to do. So whenever the first print is going to come those are going to give the first print from the machine. So that is why it is known as an first in first out it makes and schedule of the printer from which the printer is going to take the numbers from where the print is going to come here. In the similar manner that is a job scheduling it is known as a multitasking. So whenever you are going to have more than one task going to do done in a computer applications so the CPU starts to do and scheduling of that here. So that is known as a job scheduling here. In the similar manner that is in real time simulations so for example the railway reservation counters. So as we see in the smaller cities the population is less where the reservation counters are very less means up to 5 to 6 reservation counters are there in Solapur city but as we move on to the metro cities like Pune, Mumbai so in where there are 30 to 40 reservation counters. So how they are going to build why they have built so many reservation counters here. So they calculate the arrival time of the person they calculate when the person is leaving from that place. So how much time is required to get the service from the user or the client. So based on this analysis that is done on the base on the queue only. So that is why if there are more number of queues and the person is getting more time to get the service then they increase the reservation counters at the railway reservation. It is same with your when you are going to remove the ticket in your cinema halls. So you have multiple reservation counters here. So based on that only it is known as a real time simulation. So that are the known as an application of an queue. So in short what we can say that when the resources are shared among the multiple consumers that is include the CPU scheduling, disk scheduling, job scheduling and the simulation. So in short what we have studied is that the linear queue which follows first in first out the same thing is followed in the priority queue also but there are some priority given to the data here. So while inserting the data can be inserted anyhow but when you are going to remove that it can be done from the smallest elements are being removed first and the largest elements are going to be removed first that is known as the priority queue. And in double ended queue we have seen that is the input restricted DQ and the output restricted DQ and we have seen the applications of an queue. So these are my references. Thank you.