CARVIEW |
Select Language
HTTP/2 307
date: Fri, 10 Oct 2025 05:51:01 GMT
content-type: text/html
content-length: 39
location: https://how.dev/answers/what-is-a-queue
cf-ray: 98c3d7ebe99f1f95-BLR
cache-control: public, max-age=300, stale-while-revalidate=604800
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-robots-tag: all
x-nextjs-cache: MISS
x-cloud-trace-context: 54d45c99fd410e298091de73c4083b90;o=1
via: 1.1 google
alt-svc: h3=":443"; ma=86400
cf-cache-status: MISS
set-cookie: __cf_bm=nzNb_g7Nf4pqBE.4XSRkCc5wPlQ3IMtQF9KZlF5K2LU-1760075461-1.0.1.1-EejmD.ZxTWy.jV_900dt97Fou1mmIl9h9Fu4it0e63_uIDF2U6wPJYHlBt9YwJZAiDF.VYPd7QhSMlzlL2eoDibMf73TDehgnSCHnmVyrLI; path=/; expires=Fri, 10-Oct-25 06:21:01 GMT; domain=.educative.io; HttpOnly; Secure; SameSite=None
vary: Accept-Encoding
strict-transport-security: max-age=31536000; includeSubDomains; preload
server: cloudflare
HTTP/2 200
cache-control: public, max-age=300, stale-while-revalidate=604800
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
etag: W/"y2x5x00dnm6k2o"
content-type: text/html; charset=utf-8
x-cloud-trace-context: 984d92ebb6e591daf069cd1ec6b508ca
date: Fri, 10 Oct 2025 05:51:01 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache-status: miss
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