What is difference between stack and queue?

Discussion in 'Databases' started by sparkar17, Mar 25, 2010.

  1. #1
    What is difference between stack and queue?
     
    sparkar17, Mar 25, 2010 IP
  2. moneycms

    moneycms Peon

    Messages:
    265
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Stack is last in first out, queue is first in first out.
     
    moneycms, Mar 27, 2010 IP
  3. simplifythis

    simplifythis Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Both stacks and queues are like lists (ordered collections of items), but with more restricted operations. They can both be implemented either using an array or using a linked list to hold the actual items.
    A stack is a list in which all insertions and deletions are made at one end, called the top. The last element to be inserted into the stack will be the first to be removed so called last in first out[LIFO].
    A Queue is an ordered collection of items from which items may be deleted at one end (called the front of the queue) and into which items may be inserted at the other end (the rear of the queue) called [FIFO].
     
    simplifythis, Apr 1, 2010 IP