What is a stack in computer science?

Q: What is a stack in computer science?



A: A stack is a data structure used in computer science.

Q: What is an example of a stack?



A: An example of a stack is a deck of playing cards that is face down.

Q: How do we access the cards in a stack?



A: We can only easily access the card that is on top of the stack.

Q: What are the two things we can do to the top card of a stack?



A: We can peek at it, but leave it on the stack, or we can pop it off.

Q: What happens when we pop off the top object of a stack?



A: When we pop off the top object, we are taking it off the stack.

Q: What do we call a collection that uses a LIFO structure?



A: A collection that uses a LIFO structure is a last-in-first-out (LIFO) collection.

Q: What is the first thing that gets pulled off a stack?



A: The first thing that gets pulled off a stack is the last thing that was added (pushed) onto it.

AlegsaOnline.com - 2020 / 2023 - License CC3