QUEUE
A Queue is a linear data
structure.This data structure
follows a particular order in
which the operations are
performed.The order is First
In First Out (FIFO).
Here's how a queue works:
1. Enqueue: Elements are added to the
end of the queue.
2. Dequeue: Elements are removed from
the front of the queue.
3. Front: The element at the front of the
queue is the next one to be removed.
4. Rear: The element at the end of the
queue is the last one that was added.
Primary Queue Operations:
void enqueue(int Element): When this operation
is performed, an element is inserted in the queue
at the end i.e. at the rear end.
int dequeue(): When this operation is
performed, an element is removed from the front
end and is returned.
void Enqueue (int x);
int Dequeue ();
int front(): This operation will return the element at the
front without removing it and it take O(1) time.
int rear(): This operation will return the element at the
rear without removing it, Its Time Complexity is O(1).
Int is Empty(): This operation indicates whether the
queue is empty or not. This Operation also done in O(1).
int size(): This operation will return the size of the
queue i.e. the total number of elements present in the
queue and it’s time complexity is O(1).
Auxiliary Queue Operations:
Types of Queues:
Simple Queue: Simple queue also known as a linear queue is
the most basic version of a queue.
Circular Queue: This is mainly an efficient array implementation
of Simple Queue. In a circular queue, the element of the queue
act as a circular ring.
Priority Queue: This queue is a special type of queue. Its
specialty is that it arranges the elements in a queue based on
some priority.
Dequeue: Dequeue is also known as Double Ended Queue. As
the name suggests double ended, it means that an element can
be inserted or removed from both the ends of the queue unlike
the other queues in which it can be done only from one end.
Advantages of Queue:
• A large amount of data can be managed
efficiently with ease.
• Operations such as insertion and deletion can
be performed with ease as it follows the first in
first out rule.
• Queues are useful when a particular service is
used by multiple consumers.
• Queues are fast in speed for data inter-process
communication.
• Queues can be used in the implementation of
other data structures.
Disadvantages of Queue:
• The operations such as insertion and
deletion of elements from the middle are
time consuming.
• In a classical queue, a new element can
only be inserted when the existing
elements are deleted from the queue.
• Searching an element takes O(N) time.
• Maximum size of a queue must be
defined prior in case of array
implementation.
GROUP2.pptxfdfffffffffffffffffffffffffffffffffffffffffff

GROUP2.pptxfdfffffffffffffffffffffffffffffffffffffffffff

  • 1.
  • 2.
    A Queue isa linear data structure.This data structure follows a particular order in which the operations are performed.The order is First In First Out (FIFO).
  • 3.
    Here's how aqueue works: 1. Enqueue: Elements are added to the end of the queue. 2. Dequeue: Elements are removed from the front of the queue. 3. Front: The element at the front of the queue is the next one to be removed. 4. Rear: The element at the end of the queue is the last one that was added.
  • 5.
    Primary Queue Operations: voidenqueue(int Element): When this operation is performed, an element is inserted in the queue at the end i.e. at the rear end. int dequeue(): When this operation is performed, an element is removed from the front end and is returned. void Enqueue (int x); int Dequeue ();
  • 6.
    int front(): Thisoperation will return the element at the front without removing it and it take O(1) time. int rear(): This operation will return the element at the rear without removing it, Its Time Complexity is O(1). Int is Empty(): This operation indicates whether the queue is empty or not. This Operation also done in O(1). int size(): This operation will return the size of the queue i.e. the total number of elements present in the queue and it’s time complexity is O(1). Auxiliary Queue Operations:
  • 7.
    Types of Queues: SimpleQueue: Simple queue also known as a linear queue is the most basic version of a queue. Circular Queue: This is mainly an efficient array implementation of Simple Queue. In a circular queue, the element of the queue act as a circular ring. Priority Queue: This queue is a special type of queue. Its specialty is that it arranges the elements in a queue based on some priority. Dequeue: Dequeue is also known as Double Ended Queue. As the name suggests double ended, it means that an element can be inserted or removed from both the ends of the queue unlike the other queues in which it can be done only from one end.
  • 8.
    Advantages of Queue: •A large amount of data can be managed efficiently with ease. • Operations such as insertion and deletion can be performed with ease as it follows the first in first out rule. • Queues are useful when a particular service is used by multiple consumers. • Queues are fast in speed for data inter-process communication. • Queues can be used in the implementation of other data structures.
  • 9.
    Disadvantages of Queue: •The operations such as insertion and deletion of elements from the middle are time consuming. • In a classical queue, a new element can only be inserted when the existing elements are deleted from the queue. • Searching an element takes O(N) time. • Maximum size of a queue must be defined prior in case of array implementation.