Stacks

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vanessa T.

    Stacks

    Hello All!

    Is there a place where I can learn stacks, (push and pop) etc.
    Thanks,


  • Ashish

    #2
    Re: Stacks


    "Vanessa T." <Sun4life@its-raining.com> wrote in message
    news:MtidnSv41c 6GCR6iU-KYuQ@comcast.co m...[color=blue]
    > Hello All!
    >
    > Is there a place where I can learn stacks, (push and pop) etc.
    > Thanks,
    >
    >[/color]



    -Ashish


    Comment

    • Guest's Avatar

      #3
      Re: Stacks

      Vanessa,

      A simple stack would be synonomous to the following:

      Bob is an office clerk. John is the boss. John puts report A in Bobs
      INBOX. Two hours later John puts report B in Bobs INBOX. Think of the
      INBOX as a stack of reports. Assume Bob always takes the report from the
      top of the INBOX and processes it. He never takes it from the bottom. Our
      stack (INBOX) looks like:

      report B
      report A

      When John places report A in the INBOX, stack terms would mean INBOX.push
      (A) or push it into the INBOX. When John places report B in the INBOX,
      stack terms would mean INBOX.push (B). When Bob goes to get a report from
      the INBOX, he doesn't care which one was placed in first, he just takes one
      off the top or he (in stack terms) INBOX.pops (B)

      push = add to top
      pop = take from top

      This type of container is what is called FILO (first in , last out) as the
      example shows.

      If you need more info...


      or


      this may be more indepth than what you are looking for
      Kevin


      "Vanessa T." <Sun4life@its-raining.com> wrote in message
      news:MtidnSv41c 6GCR6iU-KYuQ@comcast.co m...[color=blue]
      > Hello All!
      >
      > Is there a place where I can learn stacks, (push and pop) etc.
      > Thanks,
      >
      >[/color]


      Comment

      • Karl Heinz Buchegger

        #4
        Re: Stacks



        "Vanessa T." wrote:[color=blue]
        >
        > Hello All!
        >
        > Is there a place where I can learn stacks, (push and pop) etc.
        > Thanks,[/color]

        Yep. Your kitchen! Seriously!

        Take some plates. Stack them.
        If you put a new plate on top of that stack, you 'push' it onto the
        stack.
        If you take the topmost plate from the stack, you 'pop' it from
        the stack.
        Observation: In the pop operation you always get the plate which
        was pushed last. That's why such a structure is called LIFO (last in,
        first out).

        That's all. Simple, isn't it?

        --
        Karl Heinz Buchegger
        kbuchegg@gascad .at

        Comment

        • Jonathan Mcdougall

          #5
          Re: Stacks

          > > Hello All![color=blue][color=green]
          > >
          > > Is there a place where I can learn stacks, (push and pop) etc.
          > > Thanks,[/color]
          >
          > Yep. Your kitchen! Seriously!
          >
          > Take some plates. Stack them.
          > If you put a new plate on top of that stack, you 'push' it onto the
          > stack.
          > If you take the topmost plate from the stack, you 'pop' it from
          > the stack.
          > Observation: In the pop operation you always get the plate which
          > was pushed last. That's why such a structure is called LIFO (last in,
          > first out).
          >
          > That's all. Simple, isn't it?[/color]

          One more thing : if you try to put to much plates, the can fall off
          the table (which is called a stack overflow). Not something you want.


          Jonathan


          Comment

          • rossum

            #6
            Re: Stacks

            On Wed, 8 Oct 2003 16:51:07 -0400, "Jonathan Mcdougall"
            <jonathanmcdoug all@DELyahoo.ca > wrote:
            [color=blue][color=green][color=darkred]
            >> > Hello All!
            >> >
            >> > Is there a place where I can learn stacks, (push and pop) etc.
            >> > Thanks,[/color]
            >>
            >> Yep. Your kitchen! Seriously!
            >>
            >> Take some plates. Stack them.
            >> If you put a new plate on top of that stack, you 'push' it onto the
            >> stack.
            >> If you take the topmost plate from the stack, you 'pop' it from
            >> the stack.
            >> Observation: In the pop operation you always get the plate which
            >> was pushed last. That's why such a structure is called LIFO (last in,
            >> first out).
            >>
            >> That's all. Simple, isn't it?[/color]
            >
            >One more thing : if you try to put to much plates, the can fall off
            >the table (which is called a stack overflow). Not something you want.
            >
            >
            >Jonathan
            >[/color]
            And trying to take more plates off the stack than you put on (which is
            called stack underflow) is also something you want to avoid.

            rossum

            --

            The Ultimate Truth is that there is no Ultimate Truth

            Comment

            Working...