DOC PREVIEW
TRINITY CSCI 1320 - Stacks and Queues

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Stacks and Queues11/30/20072Opening Discussion■Let's look at solutions to the interclass problem.■Linked list code.■Do you have any questions about the assignment?3Stack and Queue ADTs■Today we are going to talk about two other ADTs that are far simpler than lists.■The stack and queue ADTs each require two methods (and generally have four)■Stackpush – add something to the stackpop – remove from the stack■Queueenqueue – add something to the queuedequeue – remove something from the queue■Bothpeak – check next this to removeisEmpty – tell if it is empty4LIFO vs. FIFO■The difference between the stack and the queue is what element is removed when an element is removed.■The stack is “Last In, First Out”.■The queue is “First In, First Out”.■Note you have no control over where things go or what you pull out. The order is specified by the ADT.5Array Based Stacks■This is an easy data structure. Just keep an array and an integer index for the “top”.■When the array fills up make a bigger one.6Array Based Queues■This is a bit harder. You have to keep track of both a “front” and “back” of the queue. The trick is making it circular so you don't take up too much memory.■Modulo is a very helpful operation for making the indexes wrap around.7Linked List Based Stacks■Just as easy as the array based stack.■Use a singly linked list and add and remove from the head.8Linked List Based Queues■Perhaps easier than the array based queue.■Use a singly linked list and make the head be the “front” while the tail is the “end”.■It has to go that way because you can't efficiently remove from the tail in a singly linked list.9Code■Let's code these up as time allows.10Minute Essay■Do the linked data structures make sense to you?■Interclass Problem – Look up what a reverse Polish calculator is and write one using a stack that holds


View Full Document

TRINITY CSCI 1320 - Stacks and Queues

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Stacks and Queues
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Stacks and Queues and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Stacks and Queues 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?