Stack Data Structure Exam with Correct Answers, Exams of Advanced Education

A series of questions and answers related to the stack data structure, covering fundamental concepts, operations, and applications. It includes true/false questions, fill-in-the-blanks, and problem-solving exercises to test understanding of stack implementation using arrays and linked lists. Key topics include lifo principle, stack overflow/underflow, postfix expressions, and balancing parentheses. This resource is designed to reinforce learning and assess comprehension of stack data structures in computer science. It serves as a valuable tool for students and educators alike, offering a concise yet comprehensive review of essential stack concepts and their practical applications in various computing scenarios. Particularly useful for exam preparation and self-assessment, providing clear and concise answers to common stack-related questions.

Typology: Exams

2024/2025

Available from 07/29/2025

EXAMGUIDE
EXAMGUIDE 🇺🇸

4.4

(33)

32K documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DATA STRUCTURES STACK EXAM
WITH CORRECT ANSWERS
T/F In the Java API class java.util.Stack<E> implements a stack; there is no Stack
interface - Correct Answers -True
T/F an array can be used for storage of a stack instead of using a Java ArrayList class -
Correct Answers -True
T/F the statement Stack<String> myStack = new Stack<String>(); defines a stack that
holds String objects - Correct Answers -True
T/F there is only one stack interface in Java - Correct Answers -False
A(n) _ is a data structure in which objects are inserted into and removed from the same
end - Correct Answers -Stack
A(n) _ is a string that reads the same in either direction: left to right or right to left -
Correct Answers -Palindrome
In terms of efficiency all stack operations using an array structure are - Correct Answers
-O(1)
The value of the following postfix expression is 12+4*3+ - Correct Answers -15
Rewrite the following statement as an infix expression 56* 10- - Correct Answers -5*6-
10
A(n) _ is a data structure with the property that only the top element is accessible -
Correct Answers –Stack
Consider the implementation of the stack using an array. What goes wrong if we try to
store the top of the stack at location [0] and the bottom of the stack at the last used
position if the array - Correct Answers -Both push and pop would require linear time
In the linked list implementation of the stack class where does the push method place
the new entry on the linked list - Correct Answers -At the head
pf3

Partial preview of the text

Download Stack Data Structure Exam with Correct Answers and more Exams Advanced Education in PDF only on Docsity!

DATA STRUCTURES STACK EXAM

WITH CORRECT ANSWERS

T/F In the Java API class java.util.Stack implements a stack; there is no Stack interface - Correct Answers -True T/F an array can be used for storage of a stack instead of using a Java ArrayList class - Correct Answers -True T/F the statement Stack myStack = new Stack(); defines a stack that holds String objects - Correct Answers -True T/F there is only one stack interface in Java - Correct Answers -False A(n) _ is a data structure in which objects are inserted into and removed from the same end - Correct Answers -Stack A(n) _ is a string that reads the same in either direction: left to right or right to left - Correct Answers -Palindrome In terms of efficiency all stack operations using an array structure are - Correct Answers -O(1) The value of the following postfix expression is 12+43+ - Correct Answers - Rewrite the following statement as an infix expression 56 10- - Correct Answers -5*6- 10 A(n) _ is a data structure with the property that only the top element is accessible - Correct Answers –Stack Consider the implementation of the stack using an array. What goes wrong if we try to store the top of the stack at location [0] and the bottom of the stack at the last used position if the array - Correct Answers -Both push and pop would require linear time In the linked list implementation of the stack class where does the push method place the new entry on the linked list - Correct Answers -At the head

In the array version of the stack class, which operations require linear time for their worst case (is empty, peek, pop) - Correct Answers -None In a(n) _ the top element is the data value that was most recently stored - Correct Answers -Stack What are the methods that make up the StackInt interface - Correct Answers -Push(), pop(), peek(), empty() What is the value of the following postfix expression 561+* - Correct Answers - Is the following a balanced expression (a+b{[d-e]}) +(d/e) - Correct Answers -Yes The storage policy used by stack is what - Correct Answers -LIFO What does LIFO mean - Correct Answers -Last in first out The value of the following expression is 573 10++4/ - Correct Answers - What will an array look like after Stack s = new Stack(); S.push(1); S.push(2); S.push(3); System.out.println(s.pop()); - Correct Answers -0|1| 1|2| Top is pointed at 1s index Updates top What will a linked list look like after Stack s = new Stack(); S.push(1); S.push(2); S.push(3); System.out.println(s.pop()); - Correct Answers -|2| -> |1| Top is at 2 Update variable of head The operation for adding an entry to a stack is called - Correct Answers -Push The operation for removing an element from a stack is called - Correct Answers -Pop What stack operation could result in stack overflow - Correct Answers -Push Which stack operation could result in stack underflow - Correct Answers -Pop