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.
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.
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.
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.
CodeCall Blog | CodeCall Wiki | Shareware
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum