Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Lists, Stacks, and Queues

stack

  • Please log in to reply
2 replies to this topic

#1 Sionofdarkness

Sionofdarkness

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 370 posts

Posted 22 July 2006 - 12:44 PM

So lists can be used as stacks and queues, but what are lists, and how are stacks and queues different? I know I'm asking a lot, I'm just trying to learn the basics of the language.
  • 0

#2 brackett

brackett

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 192 posts

Posted 25 July 2006 - 10:20 PM

I'm not a Delphi or Python guy, but lists queues and stacks are pretty universal, so I'll give it a shot.

Lists: An unordered collection of objects

Stacks: An ordered collection of objects, ordered by LIFO (Last In First Out)

Queues: An ordered collection of objects, ordered by FIFO (First In First Out)

Lists are usually just accessed by index, and don't really have an order to them. You would fill them by index, and they'd keep that order.

Stacks will normally have a Push and a Pop method. Push puts an item (conceptually) on the "top" of the stack. Pop takes an item off the the "top" of the stack.

Queues will normally have an Enqueue and Dequeue method. Enqueue puts an item (conceptually) on the "bottom" of the queue. Dequeue takes an item off the "top" of the queue.
  • 0

#3 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 26 July 2006 - 05:38 PM

Also, lists, queues and stacks are used in many different languages. Some provide built in implementations, but they are examples of data-structures... usually covered in their own course.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download