Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

What is a stack? #

Sumit Rawal answered on July 10, 2021 Popularity 10/10 Helpfulness 1/10

Contents


More Related Answers

  • PEAN stack
  • java stack
  • stack register
  • Mevn stack
  • std::stack
  • java stack
  • mean stack
  • c# stack
  • c# stack
  • Java Creating a Stack
  • what is mean stack
  • c# stack
  • mean stack tutorial
  • Stack Push
  • Stack Trace
  • create stack data structure
  • stack data structure
  • create stack data structure
  • stack empty
  • Stack java
  • create stack data structure
  • Stack POP
  • Stack Push
  • What are the basic operations of a stack?
  • create stack data structure
  • create stack data structure
  • c# stack
  • create stack data structure

  • What is a stack? #

    4

    First of all, let me describe what a stack is. Based on the name, it should be a relatively familiar concept.

    Let’s assume that we have four books with the following riveting titles:

    A

    B

    C

    D

    At the moment, these books are strewn out all over the floor and we want to stack them up neatly.

    Four books are lying all over the place.

    1 of 5

    Now we have a nice neat stack of books! If we want to retrieve a book from this stack, we can take the book on top. Taking a book from the bottom is a bit precarious and we don’t want to topple the entire stack. Therefore, we’ll take down the top book on the stack and read it or do whatever we want to do with it.

    Let’s say we want to take Book A. Right now, it is at the bottom of the stack, so we need to take Book D, put it down, then do the same for Book C and Book B, and then we can access Book A.

    This is the main idea of a stack. The data structure stack is very similar to a physical stack that you’d most likely be familiar with. The stack data structure allows us to place any programming artifact, variable or object on it, just as our example stack allowed us to put books in it.

    Popularity 10/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Tags: whatever
    Link to this answer
    Share Copy Link
    Contributed on May 18 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10

    Closely Related Answers



    1
    Popularity 10/10 Helpfulness 2/10 Language whatever
    Source: Grepper
    Tags: stack stac
    Link to this answer
    Share Copy Link
    Contributed on Jul 10 2021
    Wide-eyed Wombat
    0 Answers  Avg Quality 2/10

    1
    Popularity 10/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Tags: stack stac
    Link to this answer
    Share Copy Link
    Contributed on Nov 26 2023
    Magnificent Moose
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.