CARVIEW |
Select Language
HTTP/2 307
date: Sat, 11 Oct 2025 22:55:43 GMT
content-type: text/html
content-length: 39
location: https://how.dev/answers/what-is-a-queue
cf-ray: 98d1f2538901cf00-BLR
cache-control: public, max-age=300, stale-while-revalidate=604800
referrer-policy: strict-origin-when-cross-origin
x-app-version: v251008-h-251010-1202
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-app-type: Learn
x-robots-tag: all
x-nextjs-cache: MISS
x-cloud-trace-context: 7841b297caaf035bc7baa5af6f45aed0;o=1
via: 1.1 google
alt-svc: h3=":443"; ma=86400
cf-cache-status: MISS
set-cookie: __cf_bm=7_a.N6mEgRhgM9B0txfxAC6zf4SKIfvqCKWicb3K6tY-1760223343-1.0.1.1-SfNI.J37ehldWfyPDi4rgfmsq8hSAqSOsjeDy_kdiffGOgVH9KcOT52ptEwlXHnwsfNCMh3ssePa10.PCEY0AwFMT1iwyVx2iOCMtnnp5Mg; path=/; expires=Sat, 11-Oct-25 23:25:43 GMT; domain=.educative.io; HttpOnly; Secure; SameSite=None
vary: Accept-Encoding
strict-transport-security: max-age=31536000; includeSubDomains; preload
server: cloudflare
HTTP/2 200
referrer-policy: strict-origin-when-cross-origin
x-app-version: v251007-rb-251009-1112
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-app-type: Learn
x-middleware-rewrite: /answers/howdev/what-is-a-queue
x-nextjs-cache: HIT
x-cloud-trace-context: 984d92ebb6e591daf069cd1ec6b508ca
server: Google Frontend
via: 1.1 google
content-encoding: gzip
date: Fri, 10 Oct 2025 05:51:01 GMT
cache-control: public, max-age=300, stale-while-revalidate=604800
etag: W/"y2x5x00dnm6k2o"
content-type: text/html; charset=utf-8
vary: Accept-Encoding
content-length: 55876
age: 147882
x-cache-status: stale
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
What is a queue?
What is a queue?
A queue is another common data structure that places elements in a sequence, similar to a stack. A queue uses the FIFO method (First In First Out), by which the first element that is enqueued will be the first one to be dequeued.
Let’s look at a real-life example: A line of people waiting at a concert. A new person arriving would join the end of the line, while the person at the front of the line would leave the line and enter the venue.
Basic operations of a queue
-
Enqueue() — Inserts an element to the end of the queue
-
Dequeue() — Removes an element from the start of the queue
-
isEmpty() — Returns true if queue is empty
-
Top() — Returns the first element of the queue
Relevant Answers
Explore Courses
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved