Mindmap
Stack(for mid term)
Inhalt der Mindmap
Stack(for mid term)
follows Last In First Out or First In Last Out
Stack class extends class Vector with five operations that allow a vector to be treated as a stack.
- push(item)
- Pushes an item onto the top of this stack
- pop()
- Removes the object at the top of this stack and returns that object as the value of this function.
- throws EmptyStackException - if stack is empty.
- peek()
- Looks at the object at the top of this stack without removing it from the stack.
- EmptyStackException - if this stack is empty.
- empty()
- true if and only if this stack contains no items; false otherwise.
- search(object o)
- the 1-based position from the top of the stack where the object is located; the return value -1 indicates that the object is not on the stack.
- he topmost item on the stack is considered to be at distance 1
- push(item)
Constructor
- Stack() ... Creates an empty Stack.
it also inherits many methods from class java.util.vector and java.lang.object
create stack
- import java.util.stack package
- Stack<E> stack = new Stack<E>();
- import java.util.stack package
print stack
- System.out.println(stack);
- elements are printed in order from bottom to top
- System.out.println(stack);
exceptions
- Underflow: Trying to pop/peek an element from an empty stack
- Overflow: Trying to push an element into a stack that is already at its maximum capacity
parenthesis matching problem
- mug up entire code
- more topics in module
file versioning system
- understand given code thoroughly
implementing stack
- using Array, arraylist and linked list
Informationen
- Beschreibung
- Mindmap am Stack(for mid term), erstellt von abhay jagetiya am 06/10/2021.
- Erstellt von
- abhay jagetiya
- Aufrufe
- 0
- Bewertung