An integer stack starts empty, and the eight operations in the table run in order from top to bottom. A pop removes and returns the top element. A peek returns the top element without removing it. A push returns nothing. Fill in the value each pop or peek returns, the top element after each operation, and the number of elements on the stack after each operation.

OperationValue returnedTop after operationSize after operation
push(7)none
push(3)none
push(9)none
pop()
push(5)none
peek()
pop()
pop()

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A stack is a linear collection in which push and pop both act at one end only, called the of the stack. Calling pop on an empty stack is an error called stack , and calling push on a fixed-capacity stack that is already full is an error called stack .

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A stack is implemented with a dynamic array that doubles its capacity when full, and the top of the stack is kept at the end of the array (the highest occupied index). Which of the following statements about this stack are true? Select all that apply.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors