Queue in data structure | Introduction to queues | data structures | queues in java
Описание
Here we have started Data Structures Complete Course. In this course ,We will try our best to delivery knowledge to you guys. If you like our videos then subscribe our channel and also share it with your friends and fellows.
Here is the Detail of Lecture :
Queue is also an abstract data type or a linear data structure, just like stack data structure, in which the first element is inserted from one end called the REAR(also called tail), and the removal of existing element takes place from the other end called as FRONT(also called head).
This makes queue as FIFO(First in First Out) data structure, which means that element inserted first will be removed first.
Queue operations may involve initializing or defining the queue, utilizing it, and then completely erasing it from the memory. Here we shall try to understand the basic operations associated with queues −
enqueue() − add (store) an item to the queue.
dequeue() − remove (access) an item from the queue.
Few more functions are required to make the above-mentioned queue operation efficient. These are −
peek() − Gets the element at the front of the queue without removing it.
isfull() − Checks if the queue is full.
isempty() − Checks if the queue is empty.
Applications of Queue
Queue, as the name suggests is used whenever we need to manage any group of objects in an order in which the first one coming in, also gets out first while the others wait for their turn, like in the following scenarios:
Serving requests on a single shared resource, like a printer, CPU task scheduling etc.
In real life scenario, Call Center phone systems uses Queues to hold people calling them in an order, until a service representative is free.
Handling of interrupts in real-time systems. The interrupts are handled in the same order as they arrive i.e First come first served.
Implementation
enQueue(q, x):
While stack1 is not empty, push everything from stack1 to stack2.
Push x to stack1 (assuming size of stacks is unlimited).
Push everything back to stack1.
Here time complexity will be O(n)
deQueue(q):
If stack1 is empty then error
Pop an item from stack1 and return it
Here time complexity will be O(1)
#datastructures
#datastructuresandalgorithms
#binary
#binarysearchtree
#binarysearch
#data
#sortingalgorithm
#searching
#searchingAlgorithm
#datastructure
#datastructureandalgorithm
#datastructureinhindi
#stack
#queues
#queue
In the case of any queries Contact us at:
Email us:
thekacs002@gmail.com
Like us on Facebook:
Link: https://www.facebook.com/TheKacsAcademy/
Follow us on Twitter:
Link : https://twitter.com/Zeeshan99237099
Instagram :
Link : https://www.instagram.com/thekacs6
#Subscribe #Data_Structure #KacsAcademy
Рекомендуемые видео
















