Recent questions tagged goclasses-da-dpp

4 4 votes
1 1 answer
179
179 views
The following strings are inserted into an empty Binary Search Tree in the given order, using normal lexicographic dictionary order:$\text{Paris, London, Rome, Vienna, Du...
5 5 votes
3 3 answers
249
249 views
Assume height is counted as the number of nodes on the longest root-to-leaf path.A Binary Search Tree contains exactly $403$ nodes.Which option gives the minimum possible...
4 4 votes
1 1 answer
177
177 views
Which of the following statements about Binary Search Trees is correct?If $\texttt{y}$ is in the left subtree of node $\texttt{x}$, then $\texttt{y.key >= x.key}$. If $\t...
4 4 votes
2 2 answers
259
259 views
The postorder traversal of a binary search tree is:$\text{1, 12, 4, 22, 18, 16}$What is the new postorder traversal after inserting $10$ and $14$ into the BST?$\text{1, 1...
6 6 votes
1 1 answer
222
222 views
A binary tree has:Left subtree containing $1000$ nodes Right subtree containing $100$ nodesHow many nodes are processed before the root in preorder, inorder, and postorde...
5 5 votes
2 2 answers
225
225 views
A binary tree has the following traversals:Preorder traversal $: \text{A M P K L D H T}$ Inorder traversal $:\text{P M L K A H T D}$Which of the following is the postorde...
6 6 votes
1 1 answer
181
181 views
Consider the following binary tree:Which option correctly gives the preorder, postorder, inorder, and level-order traversals?Preorder $:\texttt{9 15 23 12 8 6 2 7 10 5 35...
6 6 votes
1 1 answer
159
159 views
Consider the following binary search tree:If we traverse the tree in postorder and print only the key values that are greater than $12$ and less than $20$, what will be t...
6 6 votes
1 1 answer
201
201 views
A node of a binary tree is called nearly balanced if one of the following holds:The node is a leaf. The node has one child and that child is a leaf. The node has two chil...
6 6 votes
2 2 answers
234
234 views
A complete binary tree is stored in an array using $\mathbf{1}$-based indexing, where the root is stored at index $1$.For a node stored at index $11$, which of the follow...
7 7 votes
1 1 answer
194
194 views
A binary tree has height $4$, where height is measured as the maximum number of edges from the root to a leaf.Can such a binary tree have exactly $8$ leaves?Yes, because ...
0 0 votes
1 1 answer
108
108 views
Consider the following dictionary:goals = {"Country":{"Ronaldo":123,"Messi":103,"Pele":83}, "Club":{"Ronaldo":[512,51,158],"Pele":[604,49,26]}}Which of the following stat...
7 7 votes
1 1 answer
307
307 views
Assume there are $n$ elements in the data structure. Consider the following statements:$\text{S1}:$ A stack can be implemented using a linked list such that each individu...
0 0 votes
1 1 answer
102
102 views
A queue follows FIFO order. Consider the following operations on an initially empty queue:q = [] q.append("A") q.append("B") q.append("C") x = q.pop(0) q.append("D") y = ...
0 0 votes
1 1 answer
139
139 views
A queue is to be implemented using two stacks and only a constant amount of extra memory. Which of the following correctly implements queue behavior with constant amortiz...
0 0 votes
1 1 answer
87
87 views
Give the running time of each operation in the following queue class, where the item most recently inserted is at $\texttt{_a[0]}$.class Queue: def __init__(self): self._...
0 0 votes
1 1 answer
86
86 views
Give the running time of each operation in the following queue class, where the item least recently inserted is at $\texttt{_a[0]}$.class Queue: def __init__(self): self....
4 4 votes
1 1 answer
195
195 views
Suppose a client performs an intermixed sequence of $\texttt{enqueue}$ and $\texttt{dequeue}$ operations on a queue. The enqueue operations put the integers $0$ through $...
2 2 votes
2 2 answers
154
154 views
Consider the following postfix expression:$\texttt{1 2 3 + 4 5 * * +}$Which of the following fully parenthesized infix expressions is equivalent to it?$\texttt{( 1 + ( ( ...
2 2 votes
2 2 answers
117
117 views
Consider the following prefix expression:$\texttt{+ * 2 3 / 8 4}$Which of the following is its correct postfix form?$\texttt{2 3 * 8 4 / +}$$\texttt{+ * 2 3 / 8 4}$$\text...
2 2 votes
2 2 answers
140
140 views
For the expression:$\texttt{2 * 3 + 8 / 4}$Assume the expression tree has $\texttt{+}$ as the root, $\texttt{*}$ as the left subtree root, and $\texttt{/}$ as the right s...
2 2 votes
2 2 answers
117
117 views
3 3 votes
2 2 answers
129
129 views
Convert the following fully parenthesized infix expression into postfix form:$\texttt{( 2 + ( ( 3 + 4 ) * ( 5 * 6 ) ) )}$Which of the following is the correct postfix exp...
1 1 vote
2 2 answers
133
133 views
Consider the following Python code fragment:stack = [] while len(q) 0: stack.append(q.pop(0)) while len(stack) 0: q.append(stack.pop())Here, $\texttt{q.pop(0)}$ removes...
1 1 vote
2 2 answers
126
126 views
Consider the following stack-based Python code:stack = [] n = 50 while n 0: stack.append(n % 2) n = n // 2 while len(stack) 0: print(stack.pop(), end="")What is printed...
5 5 votes
2 2 answers
245
245 views
A stack is used to check whether parentheses, braces, and brackets are properly balanced.Consider the following two inputs:Input $1: \texttt{[()]\{\}\{[()()]()\}}$Input $...
6 6 votes
3 3 answers
320
320 views
Suppose an intermixed sequence of stack push and pop operations is performed. The push operations push the integers $0$ through $9$ in order. The pop operations print the...
7 7 votes
3 3 answers
285
285 views
A stack client reads tokens from left to right. If the token is a word, it is pushed onto the stack. If the token is $\texttt{-}$, one item is popped and printed.Consider...
1 1 vote
2 2 answers
141
141 views
Which of the following expressions correctly describe $\mathrm{T}(n) = n^2 \log n$?Select all that apply.$\mathrm{O}(n^2)$$\mathrm{\Theta(n^2)}$$\mathrm{\Omega(n^2)}$$\ma...