Posts

Priority Queue

Priority queue:-  It is a special type of queue which stores group of elements. Each element has a priority number associated with it. Priority queue is an ADT (Abstract Data Type) which is like a regular queue or data structure but it will provide services on the basis of priority of an element. यह एक विशेष प्रकार का क्यू होता है जो एलिमेंट्स का समूह रखता है। प्रत्येक एलिमेंट से एक प्रायोरिटी नंबर संलग्न होता है। प्रायोरिटी क्यू एक ADT है जो एक सामान्य क्यू या डाटा स्ट्रक्चर के समान है परंतु यह एलिमेंट की प्रायोरिटी (प्राथमिकता) के आधार पर सुविधा प्रदान करता है। Rules of Priority Queue- प्रायोरिटी क्यू के नियम- 1. Element which has higher priority will be inserted and deleted before other elements which has lower priority. वह एलिमेंट जिसकी प्रायोरिटी अधिक होती है अन्य कम प्रायोरिटी एलिमेंट्स की तुलना में पहले इन्सर्ट एवं डिलीट किया जावेगा। 2. If two or more element has same priority then we follow FCFS (first come first serve) approach in which elements are deleted in order of the...

Double Ended Queue or Dequeue or Deque or head tail linked list

Image
Double ended queue:-  It is a special type of queue in which user can perform insertion and deletion operation at both ends of queue. Double ended queue is also known as Deque/ Dequeue/ head-tail linked list. Double ended queue is ADT. It means operations performed on double ended queue are pre-defined(fixed).We can use array and linked list representation for double ended queue. Double ended queue is mainly used in job scheduling algorithm like Steal.  यह क्यू का एक विशेष प्रकार है जिसमे यूजर इंसर्शन एवं डिलीशन ऑपरेशन क्यू के दोनों छोर से कर सकता है डबल एंडेड क्यू को डी क्यू / हेड-टेल लिंक्ड लिस्ट के नाम से भी जाना जाता है। डबल एंडेड क्यू एक ADT है, अर्थात इस पर किये जाने वाले आपरेशन पूर्व निर्धारित होते है। हम अरे या लिंक्ड लिस्ट रिप्रजेंटेशन का प्रयोग कर डबल एंडेड क्यू को मेमोरी में संग्रहित कर सकते है। यह मुख्यत: जॉब शेडूलींग अल्गोरिथम में प्रयुक्त किया जाता है जैसे - स्टील ।    Double ended queue is of following two types- डबल एंडेड क्यू दो प्रकार का ह...

Applications of Queue

  Queues are useful for following applications:- क्यू का प्रयोग, निम्न अनुप्रयोगो हेतु किया जाता है :- 1.) In network printer or printer server , A queue is used to schedule different printing jobs so that a job which is submitted earlier will be printed earlier. It provides services to all the nodes, connected in the network. So, It utilizes printing device and saving money of user. नेटवर्क प्रिंटर या प्रिंटर सर्वर में क्यू का प्रयोग विभिन्न जॉब्स को शेडुल करने के लिए किया जाता है जिससे एक जॉब जो पहले क्यू में प्रवेश करती है पहले प्रिंट की जाती है। यह नेटवर्क से जुड़े सभी नोड को सुविधा प्रदान करने का कार्य करता है जिससे प्रिंटिंग डिवाइस  का प्रभावी उपयोग होता है एवं यूजर के पैसो की बचत होती है।      2.) In simulation of Airport/ Railway station etc we can use different queues for passengers information, ticket reservation, seat allotment, flight/train information, runway/ track details etc. it requires 100% accuracy, which is not possible manually. एअरपोर्ट एवं ...

Circular Queue Data Structure, C or C++ Program for Insertion, Deletion and Traversing Operations of Circular Queue.

Image
  Circular Queue:- Circular queue is a special type of queue in which last position and first position are assumed as adjacent position. It means in circular queue first position will occur after last position. It is a linear data structure. It is collection of ordered data elements. It is also known as FIFO system or FCFS system. It means an element which is inserted first will be deleted first. Here data elements will be inserted from one end of queue called rear and deleted from the other end called front. We can use Array or Linked list representation to store circular queue in memory.  Hence, we assume first and last position are adjacent in circular queue and resolve this problems of linear/static queue. It is more effective technique than physical queue. सर्कुलर क्यू एक विशेष प्रकार का क्यू होता है जिसमे फर्स्ट और लास्ट पोजीशन को एक दुसरे के नजदीक(आस-पास) माना जाता है  अर्थात लास्ट पोजीशन के बाद हमेशा फर्स्ट पोजीशन आती है। यह एक लीनियर डाटा स्ट्रक्चर है। यह क्रमबद्...

Disadvantage of Linear / Static Queue and Its Solution

Disadvantage of Linear/Static Queue-  लीनियर/स्टेटिक क्यू की हानियाँ:- We know that when any element is inserted in linear queue then rear will be increased by 1. Let, assume after insertion operations rear is shifted to last position(N-1) in queue. It means, now queue is full. Now if a new element is inserted then overflow condition will occur. Now, if we delete some elements from queue then front will be increased by 1. After deletion memory space occupied by those elements will be blank and it should be reused by other new element. But it cannot possible because rear is still pointing to the last position(N-1). Hence, we cannot able to reuse free memory space present in linear/static queue and memory is not effectively used. To solve this problem following two types are used. हमे ज्ञात है कि जब लीनियर क्यू में किसी नए एलिमेंट को इन्सर्ट किया जाता है तब रियर को एक से बढाया जाता है। माना कि कई इंसर्शन ऑपरेशन के पश्चात् रियर अभी लास्ट पोजीशन(N-1) पर है अर्थात क्यू फुल है और अब इंसर...

C++ or C program for Insertion, Deletion, Traversing operations of Linear or Static Queue

File Name:- queue.cpp #include<iostream.h> #include<conio.h> #define N 5 int queue[N],front=-1,rear=-1,item; //insertion function void insertion(){ if(rear==N-1){ cout<<"Overflow Condition"<<endl; getch(); return; } cout<<"Enter an Item to insert"<<endl; cin>>item; if(rear==-1){ front=rear=0; } else{ rear++; } queue[rear]=item; cout<<"Insertion completed"<<endl<<item<<" is inserted in queue"<<endl; getch(); return; } //deletion function void deletion(){ if(front==-1){ cout<<"underflow Condition"<<endl; getch(); return; } item=queue[front]; if(front==rear){ front=rear=-1; } else { front++; } cout<<"Deletion completed"<<endl<<item<<" is deleted from queue"<<endl; getch(); return; } //traversing function void traversing(){ int i; if(front==-1){ cout<<"Queue is Empty"<<endl; getch(); ret...

Queue / Linear Queue / Static Queue Data Structure, Insertion, Deletion and Traversing Operations of Queue

Image
Linear queue:-   queue is a linear data structure. It is collection of ordered data elements. It is also known as FIFO system or FCFS system. It means an element which is inserted first will be deleted first. Here data elements will be inserted from one end of queue called rear and deleted from the other end called front. We can use Array or Linked list representation to store queue in memory.Daily life examples of queue are Students line at fees counter, Passengers line at bus stand/railway station/airport,  Viewers line at movie ticket counter etc. लीनियर/ स्टेटिक क्यू एक लीनियर डाटा स्ट्रक्चर है। यह क्रमबद्ध डाटा एलेमेंट्स का संग्रह है। इसे FIFO (फर्स्ट इन फर्स्ट आउट) या FCFS (फर्स्ट कम फर्स्ट सर्व) सिस्टम के नाम से भी जाना जाता है अर्थात क्यू में यदि किसी एलिमेंट को सबसे पहले इन्सर्ट किया जाता है, तब उसे ही सबसे पहले डिलीट किया जाता है। यहाँ एलिमेंट का इंसर्शन क्यू के रियर छोर पर तथा डिलीशन फ्रंट छोर से किया जाता है। हम अरे एवं लिंक्ड लिस्ट में से किसी एक का प्रयोग कर मेमो...