What do Push and Pop mean for Stacks?

后端 未结 9 1090
臣服心动
臣服心动 2021-01-31 18:35

long story short my lecturer is crap, and was showing us infix to prefix stacks via an overhead projector and his bigass shadow was blocking everything so i missed the importan

9条回答
  •  清歌不尽
    2021-01-31 18:53

    Hopefully this will help you visualize a Stack, and how it works.

    Empty Stack:

    |     |
    |     |
    |     |
    -------
    

    After Pushing A, you get:

    |     |
    |     |
    |  A  |
    -------
    

    After Pushing B, you get:

    |     |
    |  B  |
    |  A  |
    -------
    

    After Popping, you get:

    |     |
    |     |
    |  A  |
    -------
    

    After Pushing C, you get:

    |     |
    |  C  |
    |  A  |
    -------
    

    After Popping, you get:

    |     |
    |     |
    |  A  |
    -------
    

    After Popping, you get:

    |     |
    |     |
    |     |
    -------
    

提交回复
热议问题