Queue and Stack

i) Queue uses a First-In-First-Out(FIFO) Algorithm.

ii) Stack uses a Last-In-First-Out(LIFO) Algorithm.

Method Of Queue:

i)Enqueue (Add an item)

ii)Dequeue (Remove the fitst item)

Eg.

Module ModuleStack

       sub main()

              Dim s As New Stack

              s.Push("a1")

              s.Push("a2")

              s.Push("a3")

             s.Push("a4")

            console.writeline("first")

           dim ee as lenumerator=s.getenumerator()

           while ee.movenext

                 consol.writeline(ee.current)

          end while

           s.pop()

           s.pop()

          console.writeline("second")

           ee=s.getenumerator()

           while ee.movenext


Average Rating (0)
by Kuldip   Gamit  in VB.Net  on 4/2/2015 6:02:14 AM  


Post Your Comment
*