Group8 Report
Group8 Report
AND
HASH TABLE
STACK
• A stack is a Linear Data Structure
• STACK is a LIFO data structure (Last In First
Out)
• You can only add or remove plates from the
top
• It’s a stored Objects into a sort of “vertical
tower”
KEY OPERATIONS
ty.
STACK
EXAMPL
E
ALICE
KARINA
PHARSA CHANG’E
LYLIA
STACK
VARIABLES
Adds an elements
EXAMPLE to the top of the
ALICE
stack
KARINA
PHARSA CHANG’E
PUSH LYLIA
STACK
VARIABLES
EXAMPLE
IsFull –
Checks
LYLIA
if the
PHARSA Now Is it Full? stack is
YESS Full (for
CHANG’E
fixed-
KARINA size
stacks)
ALICE
STACK
VARIABLES
EXAMPL the Value of
E PEEK
the top
LYLIA element
PHARSA
CHANG’E
KARINA
ALICE
STACK
EXAMPLE POP –
Removes
the top
LYLIA elements
PHARSA
CHANG’E
KARINA
ALICE
STACK
VARIABLES
NEW PEEK
EXAMPLE
LYLIA
PHARSA
CHANG’E
KARINA
ALICE
STACK
VARIABLES
Code for Stack
//System.println(stack.empty());
stack.push(“Alice”);
stack.push(“Karina”);
stack.push(“Chang’e”);
stack.push(“Pharsa”);
stack.push(“Lylia”);
Continuation
stack. pop() ;
//System.println(stack.peek());
//System.println(stack.search(“Alice”));
//System.println(stack) ;
}
USES OF STACKS?
table.put(100, “SpongeBob”) ;
table.put(123, “Patrick”) ;
table.put(321, “Sandy”) ;
table.put(555, “Squidward”) ;
table.put(777, “Gary”) ;
}
}
}