DOC PREVIEW
TRINITY CSCI 1321 - Array Based Stacks and Queues

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 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 9 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 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Array Based Stacks and Queues2-15-2012Opening DiscussionDo you have any questions about the assignment?Minute essaysPrivate messages.Psychological impact of ubiquitous networking.One ServerSocket per port. Lots of Sockets going through it.3-D graphics.GUIs and networking, networked games.While loop in chatroom. Could you use for?Abstract Data Types (ADTs)Today we will be working with the simplest forms of abstract data types. These are things that hold data and specify how you can interact with it and what happens when data is added or removed.In Scala an ADT is basically a completely abstract trait for a container with comments giving details on what happens with each method.Note that it doesn't specify how things happen. That is why it would be an interface. ADTs can be implemented in many different ways.Stacks and QueuesThe simplest forms of ADTs, they each require one method to add an element and one method to remove an element. For easy of use we typically also include two other methods.Methods of a stackpush, pop, peek, isEmptyMethods of a queueenqueue, dequeue, peek, isEmptyThe Difference?Push and enqueue add items while pop and dequeue remove items. The difference is what item gets removed.A stack is last in, first out (LIFO). Just think of how you interact with a stack.A queue is first in, first out (FIFO). If you were British you would use the term queue instead of line for what you stand in when waiting for something.Array Based StackLet's write a trait called MyStack with the methods we said should be in it. Make the interface generic so it can handle any type.Now let's write a class called ArrayStack and make it extend MyStack. Fill in the code for ArrayStack and add testing.Array Based QueueNow we will do the same thing for a queue. Make a MyQueue trait and an ArrayQueue class.Other CodeOne of the most standard applications of a stack is a reverse polish calculator (RPC).Let's make a class for a RPC then make a command that will use it.Queue of commands for networking.Minute EssayQuestions?You will be turning in your project as an assignment on


View Full Document

TRINITY CSCI 1321 - Array Based Stacks and Queues

Documents in this Course
Recursion

Recursion

11 pages

Iterators

Iterators

10 pages

Actors

Actors

9 pages

Recursion

Recursion

15 pages

Recursion

Recursion

10 pages

Threads

Threads

7 pages

Trees

Trees

11 pages

Load more
Download Array Based 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 Array Based 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 Array Based 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?