Back to marketplace

Chapter 36 - Stacks

No description yet. This curated deck is ready for daily study.

Total cards: 21•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (21)

#1
Front (Question)

What is a stack?

Back (Answer)

» It is a LIFO data structure ( Last in First OUT)

#2
Front (Question)

What is LIFO?

Back (Answer)

» Items are added to the top and removed from the top » Last item to be pushed onto the stack must also be the first item to be popped fof

#3
Front (Question)

What is the main purpose of stacks?

Back (Answer)

» Hold return address when subroutines are called » Stacks are used to track the flow of the program »When subroutines end, the processor must return the PC to its previous state » We can achieve this using a stack

#4
Front (Question)

What are the 2 ways stacks can be implemented as?

Back (Answer)

» Dynamic » Static

#5
Front (Question)

What are the 2 additional variables when a stack is implemented as static(array)?

Back (Answer)

» A pointer to the top of the stack » A pointer holding the size of the array(maximum size of the stack)

#6
Front (Question)

What does push(item) do?

Back (Answer)

» Adds a new item to the top of the stack

#7
Front (Question)

What does pop() do?

Back (Answer)

» Removes and returns the top item from the stack

#8
Front (Question)

What does peek() do?

Back (Answer)

» Returns the top item from the stack but does not remove it

#9
Front (Question)

What does isEmpty() do?

Back (Answer)

» Check whether the stack is empty, and returns a Boolean value

#10
Front (Question)

What does isFull() do?

Back (Answer)

» Check whether the stack is full, and returns a Boolean valu

#11
Front (Question)

How can we test whether a stack is full?

Back (Answer)

» Examining the value of the stack pointer

#12
Front (Question)

What is a stack overflow?

Back (Answer)

» Where there is an attempt to push another item into the stack when it is already full

#13
Front (Question)

What is the value of the stack pointer if the stack is empty?

Back (Answer)

» -1

#14
Front (Question)

What is stack underflow?

Back (Answer)

» When there is an attempt to pop an item when the stack is empty

#15
Front (Question)

What is the call stack?

Back (Answer)

» Keeps track of the address of the instruction that control the subroutine, and should return to when the subroutine adds

#16
Front (Question)

What is a call stack made up of?

Back (Answer)

» Stack frames » Each stack frame corresponds to a call to a subroutine which has not yet terminated

#17
Front (Question)

How are local variables held in a stack?

Back (Answer)

» Held in a stack » Values are lost when a subroutine ends - as they are popped of the stack

#18
Front (Question)

What 3 operations can be performed on a stack?

Back (Answer)

» Pushing » Pop » Peek

#19
Front (Question)

What are the steps to push an item to a stack?

Back (Answer)

» Check for stack overflow. Ouput an error if the stack is full » Increment the stack pointer - so it points to the next available space in our array » Insert the new data item at the location pointed by the stack pointer

#20
Front (Question)

Are stacks usually dynamic data structures?

Back (Answer)

» Yes

#21
Front (Question)

What are 3 examples of data structures that are dynamic?

Back (Answer)

» Stack » Graph » List