UTEP CS 2401 - Feasibility Studies (58 pages)

Previewing pages 1, 2, 3, 4, 27, 28, 29, 30, 55, 56, 57, 58 of 58 page document View the full content.
View Full Document

Feasibility Studies



Previewing pages 1, 2, 3, 4, 27, 28, 29, 30, 55, 56, 57, 58 of actual document.

View the full content.
View Full Document
View Full Document

Feasibility Studies

13 views

Lecture Notes


Pages:
58
School:
The University of Texas at El Paso
Course:
Cs 2401 - Elem. Data Struct./Algorithms
Elem. Data Struct./Algorithms Documents

Unformatted text preview:

Stacks and Queues Chris Kiekintveld CS 2401 Fall 2010 Elementary Data Structures and Algorithms Two New ADTs Define two new abstract data types Both are restricted lists Can be implemented using arrays or linked lists Stacks Last In First Out LIFO Queues First In First Out FIFO Java Programming Program Design Including Data Structures 2 Stacks List of the same kind of elements Addition and deletion of elements occur only at one end called the top of the stack Computers use stacks to implement method calls Stacks are also used to convert recursive algorithms into nonrecursive algorithms Java Programming Program Design Including Data Structures 3 Conceptual Stacks Figure 17 1 Various types of stacks Java Programming Program Design Including Data Structures 4 Stacks continued Stacks are also called Last Input First Output LIFO data structures Operations performed on stacks Push adds an element to the stack Pop removes an element from the stack Peek looks at the top element of the stack Java Programming Program Design Including Data Structures 5 Stacks continued Figure 17 3 Stack operations Java Programming Program Design Including Data Structures 6 Stacks continued Figure 17 4 UML diagram of the interface StackADT Java Programming Program Design Including Data Structures 7 StackException Class Adding an element to a full stack and removing an element from an empty stack would generate errors or exceptions Stack overflow exception Stack underflow exception Classes that handle these exceptions StackException extends RunTimeException StackOverflowException extends StackException StackUnderflowException extends StackException Java Programming Program Design Including Data Structures 8 Implementation of Stacks as Arrays The array implementing a stack is an array of reference variables Each element of the stack can be assigned to an array slot The top of the stack is the index of the last element added to the stack To keep track of the top position declare a variable called



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Feasibility Studies 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 Feasibility Studies 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?