Discussion
You are given a set \(V\) of distinct integers. A binary search tree \(T\) is created by inserting all elements of \(V\) one by one, starting with an empty tree. The tree \(T\) follows the convention that, at each node, all values stored in the left subtree of the node are smaller than the value stored at the node. You are not aware of the sequence in which these values were inserted into \(T\), and you do not have access to \(T\).
Which one of the following statements is TRUE?
Answer: A
The true statement is Inorder traversal of \(T\) can be determined from \(V\).
An inorder traversal of a binary search tree visits the left subtree, the node, then the right subtree, so it always lists the keys in increasing order, whatever the tree's shape. Sorting V therefore gives the inorder traversal without knowing T.
The root is the first value inserted, and the shape of the tree depends on the whole insertion order, so the root, the preorder and the postorder traversals all change with that order. For example, inserting 1, 2, 3 and 2, 1, 3 gives different roots and different preorders.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development