answersLogoWhite

0


Best Answer

A queue is a first in, first out (FIFO) data structure. Queues are typically used to buffer data between an input and an output device, particularly when the input and output devices operate at different frequencies. Typically one thread controls incoming data, pushing data onto the queue structure. Meanwhile another thread pops the first element from the queue and processes it. To prevent data races (where both threads update the queue concurrently) the push and pop operations are mutually exclusive. In order to perform a push or pop, a thread must first acquire a lock. If the lock is already held by another thread, the current thread is blocked. A blocked thread will yield to other threads and attempt to hold the lock on its next time-slice. Meanwhile, the thread that holds the lock can push or pop an element from queue, releasing the lock as soon as it has completed the operation.

Queues are typically implemented using a singly-linked circular list. New elements are pushed onto the tail while existing elements are popped from the head. Constant-time access to both the head and tail is achieved through a single pointer to the tail, which points "forwards" to the head.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

A queue is a first-in, first out (FIFO) sequence container. The two primary operations are push() and pop(), where push() inserts a new element at the end of the queue and pop() extracts an existing element from the front of the queue. Secondary operations include clear() which empties the queue, count() which returns the current number of elements in the queue, and empty() which returns true if the count is zero (the queue is empty).

Queues are typically implemented as a singly-linked list (a forward list), maintaining pointers to both the head (for extractions) and the tail (for insertions) along with a count of elements currently in the queue.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Discuss operations on the Queue

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is Queue Explain its Operations with example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is queue explain the basic element of queue?

The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )


What is a queue Explain various operations perfomed using stack with examples?

Stack has the following operations:1) push - insert an element into the stack2) pop - remove an element out of the stack3) top - display the topmost element in the stackQueue has the following operations:1) enqueue - insert an element into the queue2) dequeue - remove an element from the queue3) front - display the element at the front of the queue(next element to be dequeued)4) rear - display the element at the rear of the queue(last element enqueued)The following operations can be performed in both stack and queue:1) size - returns the size of the container2) isempty - returns whether the container is empty or not


Can you give the explanation for various operations in a queue implementation using arrays?

The following are operations performed by queue in data structuresEnqueue (Add operation)Dequeue (Remove operation)Initialize


What is time complexity of stack?

All major queue operations (push, pop and front) are constant time operations.


What are the various operations that can be performed on a queue?

In queue insertion takes place on rear end and deletion takes place on front end. INSERTION(QUEUE,N,FRONT,REAR,ITEM) :QUEUE is the name of a array on which we are implementing the queue having size N. view comlete ans at http://mcabcanotes.in/algorithm-to-perform-insertion-and-deletion-in-a-queue/

Related questions

What is circular queues Explain in detail along with example?

circular queue


What is queue explain the basic element of queue?

The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )


What is a queue Explain various operations perfomed using stack with examples?

Stack has the following operations:1) push - insert an element into the stack2) pop - remove an element out of the stack3) top - display the topmost element in the stackQueue has the following operations:1) enqueue - insert an element into the queue2) dequeue - remove an element from the queue3) front - display the element at the front of the queue(next element to be dequeued)4) rear - display the element at the rear of the queue(last element enqueued)The following operations can be performed in both stack and queue:1) size - returns the size of the container2) isempty - returns whether the container is empty or not


List out atleast 5 rela life instances where queue and circular queue operations are being used?

1. List out atleast 5 rela life instances where queue and circular queue operations are being used.


How do you use queue to write a sentencs?

Example 1: I am standing in the ATM queue Example 2: Please be in queue


Can you give the explanation for various operations in a queue implementation using arrays?

The following are operations performed by queue in data structuresEnqueue (Add operation)Dequeue (Remove operation)Initialize


What is time complexity of stack?

All major queue operations (push, pop and front) are constant time operations.


What are the various operations that can be performed on a queue?

In queue insertion takes place on rear end and deletion takes place on front end. INSERTION(QUEUE,N,FRONT,REAR,ITEM) :QUEUE is the name of a array on which we are implementing the queue having size N. view comlete ans at http://mcabcanotes.in/algorithm-to-perform-insertion-and-deletion-in-a-queue/


How do you explain the format of udp hearder and explain the udp message queue?

i want argent answer


What are the primitive operation perform on a stack and queue?

Primitive Operations : enqueue(o) Put object o on the end of the queue. dequeue() Remove and return the object at the front of the queue. head() Reveal the front object in the queue, but do not remove it. size() Return the number of objects currently in the queue. capacity() Return the maximum number of objects the queue can hold. Other operations can be defined in terms of these primitive on es. For example: • isEmpty() can be defined by testing whether size() is 0. • isFull() can be defined by testing whether size() equals the capac- ity(). These last two could also be considered primitive operation s. There is a balance between minimizing the set of primitive operation s, versus providing many convenient operations for users.


List out atleast 5 real life instances where queue and circular queue operations are being used?

A>People will stand on queue for getting a film tickets. B>In Airport the luggage will be flowing in a queue manner. C>Children will walk into the school in queue. D>Getting into the temple we have to stand in a queue. E>School children will do the prayer with a proper queue.


What is circular queue operations circular queue?

A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. Advantage of this type of queue is that empty location let due to deletion of elements using front pointer can again be filled using rear pointer. There are 2 conditions for queue full if queue is implemented using arrays. First condition is Front = 1 and Rear = N Second condition is Front = Rear + 1