Posts

Showing posts from April, 2020

Queue

Image
Basic Queue Operations: A queue is a data structure that is best described as "first in, first out". A queue is another special kind of list, where items are inserted at one end called the rear and deleted at the other end called the front. A real world example of a queue is people waiting in line at the bank. As each person enters the bank, he or she is "enqueued" at the back of the line. When a teller becomes available, they are "dequeued" at the front of the line. Representation of a Queue using Array: Let us consider a queue, which can hold maximum of five elements. Initially the queue is empty. 0         1          2         3          4 Q u e u e E mp t y F R O N T   = R E A R = 0 F R Now, insert 11 to the queue. Then queue status will be: 0         1