Skip to main content Accessibility help
×
Hostname: page-component-76fb5796d-x4r87 Total loading time: 0 Render date: 2024-04-27T14:02:25.492Z Has data issue: false hasContentIssue false

Chapter 5 - Stacks and Queues

Published online by Cambridge University Press:  11 August 2009

Michael McMillan
Affiliation:
Pulaski Technical College, Arkansas
Get access

Summary

Data organize naturally as lists. We have already used the Array and ArrayList classes for handling data organized as a list. Although those data structures helped us group the data in a convenient form for processing, neither structure provides a real abstraction for actually designing and implementing problem solutions.

Two list-oriented data structures that provide easy-to-understand abstractions are stacks and queues. Data in a stack are added and removed from only one end of the list; data in a queue are added at one end and removed from the other end of a list. Stacks are used extensively in programming language implementations, from everything from expression evaluation to handling function calls. Queues are used to prioritize operating system processes and to simulate events in the real world, such as teller lines at banks and the operation of elevators in buildings.

VB.NET provides two classes for using these data structures: the Stack class and the Queue class. We'll discuss how to use these classes and look at some practical examples in this chapter.

STACKS, A STACK IMPLEMENTATION, AND THE STACK CLASS

The stack is one of the most frequently used data structures, as we just mentioned. We define a stack as a list of items that are accessible only from the end of the list, which is called the top of the stack. The standard model for a stack is a stack of trays at a cafeteria.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Stacks and Queues
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Data Structures and Algorithms Using Visual Basic.NET
  • Online publication: 11 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511547010.007
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Stacks and Queues
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Data Structures and Algorithms Using Visual Basic.NET
  • Online publication: 11 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511547010.007
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Stacks and Queues
  • Michael McMillan, Pulaski Technical College, Arkansas
  • Book: Data Structures and Algorithms Using Visual Basic.NET
  • Online publication: 11 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511547010.007
Available formats
×