Back to marketplace

Section 7 Chapter 39 - Stacks

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

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

Card preview (11)

#1
Front (Question)

Stack

Back (Answer)

A data structure that functions as an ordered collection of elements where elements can be added and removed in a “Last In, First out” way

#2
Front (Question)

Applications of stacks (2)

Back (Answer)

• Going back on a web browser - Undoing

#3
Front (Question)

How to implement a stack

Back (Answer)

A list can be used to mimic a stack, with elements only being able to be either appended to the end, or removed from the end. Alternatively a static array can be used with a pointer for the top of the stack

#4
Front (Question)

Operations on a stack (5)

Back (Answer)

• push • pop • peek • isEmpty • isFull

#5
Front (Question)

Overflow of a stack

Back (Answer)

A stack will have a maximum size. An attempt to add an element to a stack that would push the size past the limit will result in a stack overflow

#6
Front (Question)

Underflow of a stack

Back (Answer)

Will occur if the stack is attempted to be popped while being empty

#7
Front (Question)

Role of a stack in subroutine calls

Back (Answer)

A call stack is used when a program is running to keep track of addresses and instructions. When a subroutine is entered, its local variables, parameters and the return address are all added to the call stack (together these values form a stack frame). When the subroutine ends the stack frame is popped and the program jumps to the return address. If there are nested subroutines then the call stack may contain many stack frames

#8
Front (Question)

Stack frame

Back (Answer)

A call stack is composed of stack frames. Each stack frame corresponds to a call to a subroutine which has not yet terminated.

#9
Front (Question)

How parameters and local variables are stored

Back (Answer)

They are both stored in the stack frame

#10
Front (Question)

Advantage of storing local variables in the stack

Back (Answer)

It is much faster than using the heap

#11
Front (Question)

Contents of a stack frame

Back (Answer)

• Local variables • Parameters • Return address