Introduction of Queue Data Structure

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.

No alt text provided for this image
Queue - Data Structure

Visit - https://www.cplusplus.in/introduction-of-queue-data-structure/

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:

  1. Enqueue –?It inserts an item or element at the rear of the queue. An error occurs if the queue is full.
  2. Dequeue –?It removes or deletes an item or element from the front end of the queue, and returns to the user. An error occurs if the queue is empty.

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:

  • Scheduling processing of GUI events printing requests.
  • Simulation orders event models real-life queue, i.e., supermarket checkout, a phone call on hold, etc.

P.S. -?I have contributed this article here - Introduction of Queue Data Structure

要查看或添加评论,请登录

Mithlesh Upadhyay的更多文章

  • Similarities between Java and C++

    Similarities between Java and C++

    Java and C++ are the two most popular programming languages. Although they have many differences, there are quite a lot…

  • Normalization in DBMS: 1NF, 2NF, 3NF and BCNF

    Normalization in DBMS: 1NF, 2NF, 3NF and BCNF

    If a table has data redundancy and is not properly normalized, then it will be difficult to handle and update the…

    1 条评论
  • Why Learn Data Structure and Algorithms?

    Why Learn Data Structure and Algorithms?

    Programming is all about data structures and algorithms. Data structures are used to hold data while algorithms are…

社区洞察

其他会员也浏览了