Introduction of Queue Data Structure
Mithlesh Upadhyay
Seeking Generative AI Data Scientist roles | Experienced in Generative AI, LLM, NLP & Python | M.Tech in Artificial Intelligence from DTU
Queue?is an ordered list in which all insertions are at one end called REAR and deletions are made at another end called FRONT. Queues are sometimes referred to as?First In First Out (FIFO)?list.
Examples of Queue:
People waiting in line at the bank queue counter from a queue.
In computers, the jobs waiting in line to use the processor for execution, this queue is known as Job Queue.
Operations of Queue:
There are two basic queue operations:
Algorithm to insert an item into Queue:
procedure insertq (item : items) ;
?{ add item to the queue q }
?begin
???if rear = n then queue is full
???else begin
???rear := rear + 1 ;
???q[rear] := item ;
领英推荐
?end ;
end ; (of insert q)
Algorithm to delete an item from Queue:
procedure deleleq (var item : items) ;
?{ delete from the front of q and return to user }
?begin
???if front = rear then queue is empty
???else begin
???item := q[front] ;
???front := front + 1 ;
???end ;
end ; (of deletion)
Application of Queue:
Queue uses the First In First Out (FIFO) order, which is good for fair (FIFO) ordering of actions. Application of Queues are:
P.S. -?I have contributed this article here - Introduction of Queue Data Structure