Recent questions tagged python-&-dsa

2 2 votes
1 1 answer
180
180 views
A hash table has $m$ slots and stores $n$ keys. Assume simple uniform hashing, so each key is equally likely to hash into any slot, independently of other keys. Collision...
2 2 votes
1 1 answer
179
179 views
For the keys : $\text{47, 61, 36, 52, 56, 33, 92}$Suppose the hash function is :$h(k) = ((10k + 4) \bmod c) \bmod 7$where $c$ is a positive integer.What is the smallest v...
4 4 votes
2 2 answers
225
225 views
Insert the integer keys$47, 61, 36, 52, 56, 33, 92$in the given order into a hash table of size $7$.The hash function is:$h(k) = (10k + 4) \bmod 7$Collisions are resolved...
6 6 votes
2 2 answers
290
290 views
In a binary tree $T$, nodes $p$, $q$, and $v$ appear in the inorder traversal as:$\ldots, p, v, q, \ldots$Node $v$ has both a left child and a right child.Which of the fo...
4 4 votes
2 2 answers
234
234 views
A Binary Search Tree has $15$ nodes. Every node except those at the lowest level has both a left child and a right child.A key is searched in this BST. The key may or may...
5 5 votes
2 2 answers
243
243 views
The following tree is a Binary Search Tree. The values $\text{a}$ to $\text{g}$ are all distinct.Which of the following gives the correct increasing order of the values?$...
6 6 votes
2 2 answers
228
228 views
Consider the following statements about Binary Search Trees.$\text{S1}:$ The largest value of a BST is the last value in the list produced by an inorder traversal. $\text...
5 5 votes
2 2 answers
206
206 views
Consider the following Binary Search Tree:The root node $7$ is deleted using a standard BST deletion algorithm. Which of the following values can become the new root whil...
2 2 votes
1 1 answer
166
166 views
The following keys are inserted into an empty Binary Search Tree in the given order:$\texttt{70, 11, 47, 81, 20, 61, 10, 12, 13, 62}$ What is the postorder traversal of t...
4 4 votes
1 1 answer
215
215 views
Consider the following statement:“$\text{Searching for an element in a balanced Binary Search Tree with N nodes will require exactly}$ $\mathrm{\log (N)}$ $\text{compare ...
4 4 votes
1 1 answer
189
189 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
289
289 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
188
188 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
286
286 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
229
229 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
231
231 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
187
187 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
167
167 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
210
210 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
242
242 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
202
202 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
110
110 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
323
323 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
109
109 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
146
146 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
91
91 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
89
89 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
208
208 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
155
155 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 + ( ( ...