Advance Data Structure Quiz-a-2

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By ADS11
A
ADS11
Community Contributor
Quizzes Created: 5 | Total Attempts: 665
| Attempts: 87 | Questions: 15
Please wait...
Question 1 / 15
0 %
0/100
Score 0/100
1. Which of the following trees have height as O(lgn) where number of nodes is n.

Explanation

R-B Tree has a height of O(lgn) where the number of nodes is n. This is because R-B Trees are balanced binary search trees that maintain a balance between the left and right subtrees. The height of an R-B Tree is always logarithmic with respect to the number of nodes, ensuring efficient operations like search, insertion, and deletion. Therefore, R-B Trees are suitable for scenarios where a large number of operations need to be performed on a dynamic set of data.

Submit
Please wait...
About This Quiz
Advance Data Structure Quiz-a-2 - Quiz

Advance Data Structure Quiz-A-2 assesses knowledge on tree-based data structures like Red-Black Trees and 2-3 Trees, focusing on properties, manipulations, and theoretical limits. Ideal for learners aiming to... see moredeepen their understanding of efficient data organization. see less

2. Which type of traversal of binary search tree outputs the value in sorted order?

Explanation

In-order traversal of a binary search tree outputs the values in sorted order because it follows the left-root-right order. This means that it first visits the left subtree, then the root node, and finally the right subtree. By visiting the left subtree first, it ensures that the smaller values are visited before the larger values, resulting in a sorted output.

Submit
3. Suppose a binary tree is constructed with n nodes, such that each node has exactly either zero or two children. The maximum height of the tree will be?

Explanation

The maximum height of a binary tree with n nodes, where each node has either zero or two children, can be found by considering the worst-case scenario. In this case, the tree will be a complete binary tree, where all levels are completely filled except possibly for the last level, which is filled from left to right. The number of nodes in a complete binary tree can be calculated using the formula 2^(height+1) - 1. Solving this equation for height, we get height = log2(n+1) - 1. Since the question asks for the maximum height, we take the ceiling of this value, which gives us (n-1)/2. Therefore, the correct answer is (n-1)/2.

Submit
4. If we first delete a key from an R-B tree and add it back then, how does the structure of resulting R-B tree compare with original R-B tree?

Explanation

When a key is deleted from an R-B tree and then added back, the resulting structure of the tree can be the same or different from the original R-B tree. This is because the structure of the resulting tree depends on the specific case and the key that was deleted and added back. In some cases, the structure may remain unchanged, while in other cases, it may be different due to the re-balancing operations performed during the deletion and re-insertion process. Therefore, it is not possible to determine whether the trees will be the same or different without considering the specific case.

Submit
5. The height of a BST is given as h. Consider the height of the tree as the no. of edges in the longest path from root to the leaf. The maximum no. of nodes possible in the tree is?  

Explanation

The correct answer is 2^(h+1) - 1. The maximum number of nodes in a binary search tree (BST) can be calculated using the formula 2^(h+1) - 1, where h is the height of the tree. This formula is derived from the fact that each node in a BST has at most two children. The height of the tree determines the number of levels, and at each level, the number of nodes doubles. Therefore, the maximum number of nodes is obtained when the tree is completely balanced and has the maximum possible height.

Submit
6. A 2-3 is a tree such that a) All internal nodes have either 2 or 3 children b) All path from root to leaves have the same length The number of internal nodes of a 2-3 tree having 9 leaves could be

Explanation

A 2-3 tree is a type of tree where all internal nodes have either 2 or 3 children. In this case, the tree has 9 leaves. To determine the number of internal nodes, we need to find the number of levels in the tree. Since all paths from the root to leaves have the same length, the number of levels in the tree will be equal to the length of any path from the root to a leaf.

Since there are 9 leaves, the length of any path from the root to a leaf will be log base 2 of 9, which is approximately 3.17. Since we need to have a whole number of levels, we can round up to the nearest whole number, which is 4. Therefore, the number of internal nodes in the 2-3 tree with 9 leaves could be 4.

Submit
7. The tree is an example of 

Explanation

A binary search tree is a type of binary tree where each node has a key that is greater than all keys in its left subtree and less than all keys in its right subtree. This property allows for efficient searching, insertion, and deletion operations. In the given question, the tree is described as an example, suggesting that it represents a specific instance of a binary search tree.

Submit
8. If we first delete a key from 2-3 tree and then add it back then, how does the structure of resulting 2-3 tree compare with original 2-3 tree?

Explanation

The structure of the resulting 2-3 tree may be the same or different from the original 2-3 tree depending on the case. When a key is deleted and then added back, the resulting tree may have the same structure as the original if the key is added back to the same location. However, if the key is added back to a different location, the structure of the resulting tree will be different from the original. Therefore, both trees may be the same or different depending on the specific case.

Submit
9. The following are the case of ...................in red black Tree

Explanation

The correct answer is "Delete". In a red-black tree, deletion of a node is one of the operations that can be performed. When a node is deleted, the tree needs to be adjusted to maintain the properties of a red-black tree, such as the balance of black nodes and the red-black coloring. Therefore, deletion is a case that needs to be considered in red-black tree operations.

Submit
10. The rotation need to be done is

Explanation

The correct answer is LL, which stands for Left Left rotation. This means that the rotation needs to be done by rotating the given object twice to the left.

Submit
11. Suppose we have numbers between 1 and 1000 in a binary search tree and want to search for the number 363. Which of the following sequence could not be the sequence of the node examined?

Explanation

not-available-via-ai

Submit
12. For a 2 -3 Tree which of the following is true

Explanation

In a 2-3 Tree, the maximum number of children that any node can have is 3. This means that a node can have up to 3 child nodes. This property of 2-3 Trees allows for efficient balancing and searching operations, as the tree can accommodate a larger number of elements in each node. Having more children per node reduces the overall height of the tree, leading to faster search and insertion times.

Submit
13. A binary search tree is generated by inserting in order the following integers: 50, 15, 62, 5, 20, 58, 91, 3, 8, 37, 60, 24 The number of the node in the left sub-tree and right sub-tree of the root, respectively, is

Explanation

The correct answer is (4,7) because when the integers are inserted in order into the binary search tree, the root node will be 50. The left sub-tree of the root will have 4 nodes (15, 5, 20, 37) and the right sub-tree of the root will have 7 nodes (62, 58, 91, 60, 24, 3, 8).

Submit
14. The run time for traversing all the nodes of a binary search tree with n nodes and printing them in an order is

Explanation

The runtime for traversing all the nodes of a binary search tree and printing them in order is O(nlg(n)). This is because in a binary search tree, each node has at most two children. Therefore, in the worst case scenario, we need to visit each node exactly once. Additionally, printing the nodes in order requires sorting them, which has a time complexity of O(nlg(n)). Therefore, the overall runtime is O(nlg(n)).

Submit
15. If n numbers are to be sorted in ascending order in O(nlogn) time, which of the following tree can be used  

Explanation

A binary tree can be used to sort n numbers in ascending order in O(nlogn) time. The binary tree can be constructed by inserting each number into the tree in a specific order. Then, by performing an in-order traversal of the tree, the numbers can be retrieved in ascending order. However, it is important to note that a binary search tree, max-heap, or min-heap cannot guarantee the O(nlogn) time complexity for sorting. Therefore, the correct answer is a binary tree.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 20, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 31, 2018
    Quiz Created by
    ADS11
Cancel
  • All
    All (15)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following trees have height as O(lgn) where number of...
Which type of traversal of binary search tree outputs the value in...
Suppose a binary tree is constructed with n nodes, such that each node...
If we first delete a key from an R-B tree and add it back then, how...
The height of a BST is given as h. Consider the height of the tree as...
A 2-3 is a tree such that ...
The tree is an example of 
If we first delete a key from 2-3 tree and then add it back then, how...
The following are the case of ...................in red black Tree
The rotation need to be done is
Suppose we have numbers between 1 and 1000 in a binary search tree and...
For a 2 -3 Tree which of the following is true
A binary search tree is generated by inserting in order the following...
The run time for traversing all the nodes of a binary search tree with...
If n numbers are to be sorted in ascending order in O(nlogn) time,...
Alert!

Advertisement