0
2.1kviews
Give ADT for the queue data structure. Discuss any two applications of queue data structure

Topic: Applications of Queue

Difficulty: Medium

Year(Marks): May2017(5 mks)

1 Answer
0
71views
  1. Queue is a linear data structure which follows First-In First- Out (FIFO) principle.
  2. In Queue Elements are added at rear end and deleted from the front end.
  3. ADT for Queue is given as follows:-

    typedef struct Queue { int rear,front; int data[max]; }queue;

  4. Consider the following diagram of Queue

enter image description here

  1. Following are the application of Queues

A. In operating systems:

  1. In an OS multiple programs are executing at the same time.

  2. Every process is associated with as state of the process which can be ready, running, blocked, wait, etc.

  3. An OS maintains a queue of all such processes. The queue is used for scheduling these processes. Whenever a process completes execution, it is removed from queue and the next in queue are given turn. When a process changes its state, it is added to the queue and gets scheduled for execution.

B. Websites:

  1. Queues are used for any situation where you want to efficiently maintain a First-in-first out order on some entities. These situations arise literally in every type of software development.

  2. Imagine you have a web-site which serves files to thousands of users. You cannot service all requests, you can only handle say 100 at once.

  3. A fair policy would be first-come-first serve: serve 100 at a time in order of arrival. A Queue would definitely be the most appropriate data structure.

Please log in to add an answer.