Close
Register
Close Window

Software Design and Data Structures

Chapter 5 Efficiency, Stacks

Show Source |    | About   «  5.1. Efficiency   ::   Contents   ::   5.3. Lab 5 Ice Creme Cone  »

5.2. Stacks

5.2.1. Objectives

Upon completion of this module, students will be able to:

  • Describe the Stack Abstract Data Type/Data Structure and the characteristics of a Stack

  • Implement Stacks in Java using an Array-Based or Linked-Chain approach

  • Develop and use Stack methods

  • Test the functionality of Stack

  • Evaluate a range of applications / use cases to determine if use of the Stack Data Structure is appropriate

5.2.2. Interactive: Introduction to Stacks [11:32]

The Stack Interface

package stack;

/**
 * An interface for the ADT stack.
 *
 * @author Frank M. Carrano
 * @author Timothy M. Henry
 * @author maellis1
 * @version May 2020
 */
public interface StackInterface<T> {
    /**
     * Adds a new entry to the top of this stack.
     *
     * @param newEntry
     *            An object to be added to the stack.
     */
    public void push(T newEntry);

    /**
     * Removes and returns this stack's top entry.
     *
     * @return The object at the top of the stack.
     * @throws stack.EmptyStackException
     *             if the stack is empty before the operation.
     */
    public T pop();

    /**
     * Retrieves this stack's top entry.
     *
     * @return The object at the top of the stack.
     * @throws stack.EmptyStackException
     *             if the stack is empty.
     */
    public T peek();

    /**
     * Detects whether this stack is empty.
     *
     * @return True if the stack is empty.
     */
    public boolean isEmpty();

    /** Removes all entries from this stack. */
    public void clear();
} // end StackInterface

Video Slides StacksIntro

5.2.3. Checkpoint 1

5.2.4. Interactive: Stack Memory Example [6:25]

5.2.5. Checkpoint 2

5.2.6. Stacks Array-Based Design [4:57]

5.2.7. Checkpoint 3

5.2.8. Stacks Array Implementation [5:57]


Video Slides StacksArrayImplementation.pdf

5.2.10. Checkpoint 4

5.2.11. Programming Practice: LinkedStacks

   «  5.1. Efficiency   ::   Contents   ::   5.3. Lab 5 Ice Creme Cone  »

nsf
Close Window