Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
15.2.2.4. Stack
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
4 cards from this lesson. Good the night before a test.
Try these first
- 1.
What does the push method do in a Stack?
Hint
Think about adding a new book on top of a stack of books.
- 2.
What does pop do in a Stack?
Hint
Consider what happens if you remove the topmost book.
- 3.
What does the 'push' operation do in a stack?
- It adds an element to the bottom of the stack.
- It removes the top element.
- It adds an element to the top of the stack.
Hint
Think about stacking items vertically.
- 4.
True or False: The peek operation removes the top element.
- True
- False
Hint
Is it more like checking the time on a clock or taking it off the wall?
- 5.
Implement a method in Java that checks for balanced parentheses in an expression using a Stack.
Hint
Consider what happens when you find an opening or closing parenthesis.
- 6.
Write a Java program that converts a decimal number to binary using a Stack.
Hint
How do the remainders help in forming the binary number?
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting