400 views
1 1 vote

In a binary search tree (BST) where all keys are distinct, which of the following properties are TRUE regarding tree traversals and structure?

  1. The In-order traversal of any BST will always yield keys in a strictly increasing sorted order.
     
  2. To find the minimum element in a non-empty BST, one must always traverse from the root to the leftmost leaf. 
     
  3. In a BST with $N$ nodes, the post-order traversal can be uniquely determined if both the in-order and pre-order traversals are provided. 
     
  4. If a BST is constructed by inserting keys in the order $\{1,2,3,4,5\}$, the resulting tree will have a height of $4 ~($where a single-node tree has height $0 )$.

1 Answer

0 0 votes
A. The In-order traversal of any BST will always yield keys in a strictly increasing sorted order.

 

Answer: True The definition of a Binary Search Tree (BST) is that for any given node, all keys in its left subtree are smaller than the node's key, and all keys in its right subtree are larger. In-order traversal visits the left subtree, then the current node, then the right subtree. This process naturally visits all nodes in ascending order of their keys.

 

B. To find the minimum element in a non-empty BST, one must always traverse from the root to the leftmost leaf.

 

Answer: False While the minimum element is found by traversing left from the root as much as possible, the traversal ends at the leftmost node which may not necessarily be a leaf node if it has a right child. The minimum element is the node with no left child in the path from the root.

 

C. In a BST with N nodes, the post-order traversal can be uniquely determined if both the in-order and pre-order traversals are provided.

 

Answer: True Given any two of the three standard tree traversals (in-order, pre-order, post-order), the structure of the binary tree can be uniquely reconstructed, and thus the third traversal can also be uniquely determined.

 

D. If a BST is constructed by inserting keys in the order {1, 2, 3, 4, 5}, the resulting tree will have a height of 4 (where a single-node tree has height 0).

 

Answer: True Inserting the keys {1, 2, 3, 4, 5} sequentially results in a skewed tree (a linked list structure to the right): 1 becomes the root. 2 is inserted as the right child of 1. 3 is inserted as the right child of 2. 4 is inserted as the right child of 3. 5 is inserted as the right child of 4. The path from the root (1) to the deepest leaf (5) has 4 edges. Given the height definition (single-node tree height 0), the height is 4.

 
Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
178
178 views
GO Classes asked Feb 3
178 views
Consider an Adjacency List representation of a directed graph $G=(V, E)$ with $n$ vertices and $m$ edges, implemented using Python's $\verb|dict|$ where keys are vertex I...
2 2 votes
1 1 answer
171
171 views
GO Classes asked Feb 3
171 views
Consider the following Python function $\verb|mystery_ds|$ that processes a list of integers:def mystery_ds(arr): stack = [] result = [0] * len(arr) for i in ...
0 0 votes
1 1 answer
157
157 views
GO Classes asked Feb 3
157 views
A binary tree $T$ is constructed such that for every node $N$, the number of nodes in its left subtree $L(N)$ and right subtree $R(N)$ satisfy the condition: $\mid \opera...
0 0 votes
1 1 answer
147
147 views
GO Classes asked Feb 3
147 views
Consider a custom Python-style hash table implementation using Linear Probing to resolve collisions. The hash table has a size of $m=11$ $($indices $0$ to $10 )$ and uses...