{"id":8795,"date":"2022-06-28T11:17:15","date_gmt":"2022-06-28T11:17:15","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=8795"},"modified":"2023-04-26T11:54:11","modified_gmt":"2023-04-26T11:54:11","slug":"difference-between-array-queue-and-stack","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/","title":{"rendered":"Difference Between Array, Queue and Stack"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg\" alt=\"\" \/><\/p>\n<h3>Array:<\/h3>\n<p>An <a href=\"https:\/\/prepbytes.com\/blog\/data-structure\/what-is-an-array-in-data-structure\/\" title=\"Array\">Array<\/a> is a collection of elements which are stored in a contiguous memory. The idea is simple i.e. to store the multiple elements together. Due to which we can easily calculate the position of each element by adding the memory location of the first element i.e. name of the array.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308579649-Image-01.png\" alt=\"\" \/><\/p>\n<h3>Queue:<\/h3>\n<p>A Queue is a linear data structure. Queue follows the FIFO rule i.e. First in First out. In other words we can say the element that goes in first is the element that comes out first.\nFor Example A ticket Queue outside a cinema hall where the person enters the queue first will get the ticket first.<\/p>\n<h3>Basic Operations of Queue:<\/h3>\n<p><strong>Enqueue:<\/strong> This operation is used to Insert an element at the end of the queue.<\/p>\n<p><strong>Dequeue:<\/strong> This operation is used to remove and return an element from the front of the queue. <\/p>\n<p><strong>isEmpty():<\/strong> This operation is used to check whether the queue is empty or not.<\/p>\n<p><strong>isFull():<\/strong> This operation is used to check whether the queue is full or not.<\/p>\n<p><strong>Peek():<\/strong> This operation is used to get the value of the element from the front of the queue.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308600264-Image-02.png\" alt=\"\" \/><\/p>\n<h3>Stack:<\/h3>\n<p>Stack is a linear data structure in which a user can insert and delete an element from the same end which is known as a top.\nStack data structure follows LIFO property i.e. Last in first out.\nIn LIFO, the element which was inserted last will be the element which was removed first.\nIn stack, the process of insertion is called push operation and the process of deletion of the element from the stack is known as pop.\nAnd, we can easily keep track of the last element using a pointer called top.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308618045-Image-03.png\" alt=\"\" \/><\/p>\n<h3>Difference between Array, Stack and Queue<\/h3>\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Array<\/th><th>Queue<\/th><th>Stack<\/th><\/tr><\/thead><tbody><tr><td>In Array, elements are accessed by <br>their indexes.<\/td><td>Queue follows FIFO principle(first in <br>first out) i.e. the element which was <br>inserted first is the element which <br>was deleted at the first.<\/td><td>Stack follows LIFO principle(Last In <br>First Out) i.e. the element which was <br>inserted first is the element which <br>was deleted at the last.<\/td><\/tr><tr><td>Insertion and deletion can be done <br>from any index in the array<\/td><td>Insertion and deletion can be done <br>from rear and front end.<\/td><td>Insertion and deletion can be done <br>from a single end.<\/td><\/tr><tr><td>Array has a fixed size.<\/td><td>Queue has both dynamic or fixed <br>size.<\/td><td>Stack has both dynamic and fixed <br>size.<\/td><\/tr><tr><td>In Array we can store elements of the <br>same data type.<\/td><td>In Queue we can store elements of <br>different data types.<\/td><td>In stack we can store elements of <br>different data types.<\/td><\/tr><tr><td>Array is of two types: 1D Array and <br>2D array<\/td><td>Queues have different types: Priority <br>queue, circular queue, double ended <br>queue.<\/td><td>Stack is only of 1 type.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n<p>This article tried to discuss the <strong>Difference between array, queue and stack<\/strong>. Hope this blog helps you understand the concept. To practice more problems feel free to check <a href=\"#\"><\/a> at  <a href=\"https:\/\/www.prepbytes.com\/\"> Prepbytes.<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Array: An Array is a collection of elements which are stored in a contiguous memory. The idea is simple i.e. to store the multiple elements together. Due to which we can easily calculate the position of each element by adding the memory location of the first element i.e. name of the array. Queue: A Queue [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[127],"tags":[40,149,187],"class_list":["post-8795","post","type-post","status-publish","format-standard","hentry","category-stacks","tag-array","tag-queue","tag-stack"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Difference Between Array, Queue and Stack | Queues | Prepbytes<\/title>\n<meta name=\"description\" content=\"Learn what is the difference between array, queue and stack.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Difference Between Array, Queue and Stack | Queues | Prepbytes\" \/>\n<meta property=\"og:description\" content=\"Learn what is the difference between array, queue and stack.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-28T11:17:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-26T11:54:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Difference Between Array, Queue and Stack\",\"datePublished\":\"2022-06-28T11:17:15+00:00\",\"dateModified\":\"2023-04-26T11:54:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/\"},\"wordCount\":502,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg\",\"keywords\":[\"array\",\"queue\",\"stack\"],\"articleSection\":[\"Stacks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/\",\"name\":\"Difference Between Array, Queue and Stack | Queues | Prepbytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg\",\"datePublished\":\"2022-06-28T11:17:15+00:00\",\"dateModified\":\"2023-04-26T11:54:11+00:00\",\"description\":\"Learn what is the difference between array, queue and stack.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Stacks\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/stacks\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Difference Between Array, Queue and Stack\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Difference Between Array, Queue and Stack | Queues | Prepbytes","description":"Learn what is the difference between array, queue and stack.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/","og_locale":"en_US","og_type":"article","og_title":"Difference Between Array, Queue and Stack | Queues | Prepbytes","og_description":"Learn what is the difference between array, queue and stack.","og_url":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-06-28T11:17:15+00:00","article_modified_time":"2023-04-26T11:54:11+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Difference Between Array, Queue and Stack","datePublished":"2022-06-28T11:17:15+00:00","dateModified":"2023-04-26T11:54:11+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/"},"wordCount":502,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg","keywords":["array","queue","stack"],"articleSection":["Stacks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/","url":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/","name":"Difference Between Array, Queue and Stack | Queues | Prepbytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg","datePublished":"2022-06-28T11:17:15+00:00","dateModified":"2023-04-26T11:54:11+00:00","description":"Learn what is the difference between array, queue and stack.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308554993-Article.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/difference-between-array-queue-and-stack\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Stacks","item":"https:\/\/prepbytes.com\/blog\/category\/stacks\/"},{"@type":"ListItem","position":3,"name":"Difference Between Array, Queue and Stack"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/8795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=8795"}],"version-history":[{"count":4,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/8795\/revisions"}],"predecessor-version":[{"id":16019,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/8795\/revisions\/16019"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=8795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=8795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=8795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}