Queue / linear queue / static queue Data Structure, Insertion, Deletion and Traversing Operations , Applications of Queue
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 (เคซเคฐ्เคธ्เค เคเคฎ เคซเคฐ्เคธ्เค เคธเคฐ्เคต) เคธिเคธ्เคเคฎ เคे เคจाเคฎ เคธे เคญी เคाเคจा เคाเคคा เคนै เค
เคฐ्เคฅाเคค เค्เคฏू เคฎें เคฏเคฆि เคिเคธी เคเคฒिเคฎेंเค เคो เคธเคฌเคธे เคชเคนเคฒे เคเคจ्เคธเคฐ्เค เคिเคฏा เคाเคคा เคนै, เคคเคฌ เคเคธे เคนी เคธเคฌเคธे เคชเคนเคฒे เคกिเคฒीเค เคिเคฏा เคाเคคा เคนै। เคฏเคนाँ เคเคฒिเคฎेंเค เคा เคंเคธเคฐ्เคถเคจ เค्เคฏू เคे เคฐिเคฏเคฐ เคोเคฐ เคชเคฐ เคคเคฅा เคกिเคฒीเคถเคจ เคซ्เคฐंเค เคोเคฐ เคธे เคिเคฏा เคाเคคा เคนै। เคนเคฎ เค
เคฐे เคเคตं เคฒिंเค्เคก เคฒिเคธ्เค เคฎें เคธे เคिเคธी เคเค เคा เคช्เคฐเคฏोเค เคเคฐ เคฎेเคฎोเคฐी เคฎें เค्เคฏू เคคैเคฏाเคฐ เคเคฐ เคธเคเคคे เคนै। เคฆैเคจिเค เคीเคตเคจ เคฎें เค्เคฏू เคे เคเคฆाเคนเคฐเคฃ เคนै - เคซीเคธ เคाเคंเคเคฐ เคे เคฌाเคนเคฐ เคाเคค्เคฐों เคी เคชंเค्เคคि , เคฌเคธ เคธ्เคैंเคก / เคฐेเคฒเคตे เคธ्เคेเคถเคจ/ เคเคฏเคฐเคชोเคฐ्เค เคฎें เคชैเคธेंเคเคฐ เคी เคฒाเคเคจ, เคฎूเคตी เคिเคेเค เคाเคंเคเคฐ เคे เคฌाเคนเคฐ เคต्เคฏूเค
เคฐเคธ เคी เคเคคाเคฐ เคเคค्เคฏाเคฆि।
Queue is mainly of five types-
เค्เคฏू เคฎुเค्เคฏเคค: เคชांเค เคช्เคฐเคाเคฐ เคा เคนोเคคा เคนै-
1. Linear/static queue (เคฒीเคจिเคฏเคฐ/ เคธ्เคेเคिเค เค्เคฏू)
2. Physical queue (เคซिเคिเคเคฒ เค्เคฏू)
3. Circular queue (เคธเคฐ्เคुเคฒเคฐ เค्เคฏू)
4. Double ended queue (เคกเคฌเคฒ เคंเคกेเคก เค्เคฏू)
5. Priority queue (เคช्เคฐाเคฏोเคฐिเคी เค्เคฏू)
Operations performed on queue are as follows:-
1. Insertion:- To add new element in queue is called insertion operation. This work is done on rear of queue and rear is increased by 1. If first element is inserted in queue then set front=rear=0. If(rear=N-1) It means queue is full and insertion operation is performed, then overflow condition will occur.
เค्เคฏू เคฎें เคिเคธी เคจเค เคเคฒिเคฎेंเค เคो เคोเฅเคจा, เคंเคธเคฐ्เคถเคจ เคเคชเคฐेเคถเคจ เคเคนเคฒाเคคा เคนै। เคฏเคน เคाเคฐ्เคฏ เค्เคฏू เคे เคฐिเคฏเคฐ เคชเคฐ เคिเคฏा เคाเคคा เคนै เคเคตं เคฐिเคฏเคฐ เคो เคเค เคธे เคฌเคขाเคฏा เคाเคคा เคนै। เคฏเคฆि เค्เคฏू เคฎें เคชเคนเคฒे เคเคฒिเคฎेंเค เคा เคंเคธเคฐ्เคถเคจ เคिเคฏा เคाเคคा เคนै เคคเคฌ front=rear=0 เคธेเค เคिเคฏा เคाเคคा เคนै। เคฏเคฆि rear=N-1 เค
เคฐ्เคฅाเคค เค्เคฏू เคซुเคฒ เคนो เคเคตं เคंเคธเคฐ्เคถเคจ เคเคชเคฐेเคถเคจ เคिเคฏा เคाเคฏे , เคคเคฌ เคเคตเคฐเคซ्เคฒो เคंเคกीเคถเคจ เคเคค्เคชเคจ्เคจ เคนोเคคी เคนै।
Algorithm / Function for Insertion operation-
void insertion(){
if(rear==N-1){
printf("Overflow Condition\n");
getch();
return;
}
printf("Enter an Item to insert\n");
scanf("%d",&item);
if(rear==-1){
front=rear=0;
}
else{
rear++;
}
queue[rear]=item;
printf("insertion completed\n");
getch();
return;
}
2. Deletion:- To remove/ delete an element from queue is called deletion. This work is done on front of queue and front is increased by 1. If last element is remained in queue i.e.. front=rear then set front=rear= -1. When front=-1, It means queue is empty and we perform deletion operation then underflow condition will occur.
เค्เคฏू เคธे เคिเคธी เคเคฒिเคฎेंเค เคो เคนเคाเคจा/ เคจिเคाเคฒเคจा , เคกिเคฒीเคถเคจ เคเคชเคฐेเคถเคจ เคเคนเคฒाเคคा เคนै। เคฏเคน เคाเคฐ्เคฏ เค्เคฏू เคे เคซ्เคฐंเค เคธे เคिเคฏा เคाเคคा เคนै เคเคตं เคซ्เคฐंเค เคो เคเค เคธे เคฌเคขाเคฏा เคाเคคा เคนै। เคฏเคฆि เค्เคฏू เคฎें เค
ंเคคिเคฎ เคเคฒिเคฎेंเค(front=rear) เคा เคกिเคฒीเคถเคจ เคिเคฏा เคाเคคा เคนै เคคเคฌ front=rear=-1 เคธेเค เคिเคฏा เคाเคคा เคนै। เคฏเคฆि front=-1 เค
เคฐ्เคฅाเคค เค्เคฏू เคाเคฒी เคนो เคเคตं เคกिเคฒीเคถเคจ เคเคชเคฐेเคถเคจ เคिเคฏा เคाเคฏे , เคคเคฌ เค
ंเคกเคฐเคซ्เคฒो เคंเคกीเคถเคจ เคเคค्เคชเคจ्เคจ เคนोเคคी เคนै।
Algorithm / Function for Deletion operation-
void deletion(){
if(front==-1){
printf("underflow Condition\n");
getch();
return;
}
item=queue[front];
if(front==rear){
front=rear=-1;
}
else
{
front++;
}
printf("Deletion completed\n");
printf("%d is deleted\n",item);
getch();
return;
}
3. Traversing:- To visit/ print of all elements of queue is called traversing. This work is done from front to rear of queue. If front= -1 or rear= -1, it means queue is empty and then Traversing operation cant be performed.
เค्เคฏू เคฎें เคเคชเคธ्เคฅिเคค เคธเคญी เคเคฒिเคฎेंเค เคो เค्เคฐेเคตเคฐ्เคธ/ เคตिเคिเค/เคเค्เคธेเคธ/เคช्เคฐिंเค เคเคฐเคจा, เค्เคฐेเคตเคฐเคธींเค เคเคชเคฐेเคถเคจ เคเคนเคฒाเคคा เคนै। เคฏเคน เคाเคฐ्เคฏ front เคธे rear เคคเค เคिเคฏा เคाเคคा เคนै। เคฏเคฆि front=-1 เค
เคฐ्เคฅाเคค เค्เคฏू เคाเคฒी เคนै, เคคเคฌ เค्เคฐेเคตเคฐเคธींเค เคเคชเคฐेเคถเคจ เคจเคนीं เคिเคฏा เคा เคธเคเคคा เคนै।
Algorithm/ Function for Traversing Operation:-
void traversing(){
int i;
if(front==-1){
printf("Queue is Empty\n");
getch();
return;
}
printf("Linear Queue is:");
for(i=front;i<=rear;i++){
printf(" %d ",queue[i]);
}
printf("front=%d and rear=%d\n",front,rear);
printf("Traversing completed");
getch();
return;
}
Example:-
Your blog explained clearly about the recent talks in the industry. For Software Courses:
ReplyDeleteSoftware testing training in chennai
JAVA Training in Chennai
Hadoop Training in Chennai
Selenium Training in Chennai
web designing Training in chennai
German Classes in chennai
Qtp training in Chennai
Qtp classes in chennai