Advance Data Structure Quiz-1

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: 263 | Questions: 15
Please wait...
Question 1 / 15
0 %
0/100
Score 0/100
1. 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 R-B tree can be the same as the original tree or different, depending on the case. This is because the structure of an R-B tree is determined by a set of rules that ensure balance and maintain the properties of a red-black tree. Deleting and adding a key can affect the balance of the tree, causing it to be the same or different from the original tree. The outcome will depend on the specific key being deleted and added, as well as the state of the tree before the operations are performed.

Submit
Please wait...
About This Quiz
Advance Data Structure Quiz-1 - Quiz

This Advance Data Structure Quiz-1 assesses knowledge on various trees like R-B Trees, 2-3 Trees, and Binary Search Trees. It explores properties, operations, and structural outcomes, enhancing understanding... see moreof complex data structures critical in computer science. see less

2. The tree is an example of 

Explanation

A binary search tree is a type of binary tree where the left child of a node contains a value smaller than the node's value, and the right child contains a value greater than the node's value. This property allows for efficient searching, insertion, and deletion operations. In the given question, the tree is described as an "example," indicating that it serves as a representation or illustration of a binary search tree. Therefore, the correct answer is binary search tree.

Submit
3. 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 visits the left subtree first, then the root, and finally the right subtree. This ensures that the values are visited in ascending order, making it an effective way to retrieve the values in sorted order from a binary search tree.

Submit
4. 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

When a key is deleted from a 2-3 tree and then added back, the resulting structure of the 2-3 tree may be the same or different from the original tree, depending on the case. This is because the structure of a 2-3 tree is determined by the specific keys that are inserted and deleted. The order in which the keys are inserted or deleted can affect the splitting and merging of nodes, which can result in different tree structures. Therefore, it is possible for the trees to be the same or different depending on the specific keys and operations performed.

Submit
5. 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

In a 2-3 tree, each internal node can have either 2 or 3 children. Since the tree has 9 leaves, there are a total of 9-1=8 internal nodes. However, not all internal nodes need to have 3 children. It is possible to have some internal nodes with 2 children and some with 3 children. Therefore, the number of internal nodes can be less than 8. The minimum number of internal nodes required to have 9 leaves is 4, where there are 3 internal nodes with 2 children each and 1 internal node with 3 children. Therefore, the correct answer is 4.

Submit
6. The rotation need to be done is

Explanation

The correct answer is "LL" because the given options represent different types of rotations in a binary tree. "LL" refers to a left rotation followed by another left rotation. This means that the left child of the root becomes the new root, and the old root becomes the right child of the new root. This rotation helps to balance the tree and maintain its structure.

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

Explanation

The correct answer is "Delete". In a red-black tree, the delete operation involves removing a node from the tree while maintaining the red-black properties. This operation requires careful restructuring and recoloring of nodes to ensure that the tree remains balanced and satisfies all the red-black tree properties. The insert and find operations also play a role in maintaining the red-black tree properties, but the delete operation specifically deals with removing nodes.

Submit
8. 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 is what differentiates a 2-3 Tree from other types of trees, where the maximum number of children per node may vary. In a 2-3 Tree, each node can have either 2 or 3 children, and the tree is balanced such that all leaf nodes are at the same height.

Submit
9. 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 the worst case, each level of the tree will be completely filled except for the last level, which may be partially filled. The number of nodes in a completely filled binary tree of height h can be calculated using the formula 2^h - 1. In this case, we want to find the maximum height, so we need to find the largest value of h such that 2^h - 1 is less than or equal to n. By solving this equation, we get h = log2(n+1) - 1. Since the height of the tree is one less than h, the maximum height can be expressed as (n-1)/2.

Submit
10. 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 maximum number of nodes possible in a binary search tree (BST) with height h can be calculated using the formula 2^(h+1) - 1. This formula is derived from the fact that at each level of the BST, the number of nodes doubles. Therefore, at the root level, there is 1 node, at the next level there are 2 nodes, at the next level there are 4 nodes, and so on. So, the total number of nodes in the BST can be calculated by summing up the number of nodes at each level, which is equivalent to 2^(h+1) - 1.

Submit
11. 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 the numbers in a specific order, such as in the order they are given or in a sorted order. Then, by performing an in-order traversal of the binary tree, the numbers can be retrieved in ascending order. This traversal takes O(n) time, and since the height of a binary tree is O(logn), the overall time complexity is O(nlogn).

Submit
12. 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 correct answer is O(nlg(n)) because in order to traverse all the nodes of a binary search tree, we need to visit each node once. The time complexity of visiting a node is O(1). Since there are n nodes in the tree, the total time complexity is O(n). Additionally, printing the nodes in order requires sorting them, which has a time complexity of O(nlg(n)) in the average case. Therefore, the overall time complexity is O(nlg(n)).

Submit
13. 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
14. Which of the following trees have height as O(lgn) where number of nodes is n.

Explanation

The Red-Black Tree has a height of O(lgn) where n is the number of nodes. This is because the Red-Black Tree is a balanced binary search tree that maintains a balance between the left and right subtrees. It achieves this balance by enforcing certain properties, such as every node being either red or black, and the number of black nodes on any path from the root to a leaf being the same. These properties ensure that the tree remains balanced and the height is logarithmic in relation to the number of nodes.

Submit
15. 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 inserting the integers in order, the first integer 50 becomes the root of the binary search tree. The integers less than 50 (15, 5, 20, 37, 24) are inserted on the left sub-tree, which results in 4 nodes. The integers greater than 50 (62, 58, 91, 60) are inserted on the right sub-tree, which results in 7 nodes. Therefore, the number of nodes in the left sub-tree and right sub-tree of the root are 4 and 7 respectively.

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 ()
If we first delete a key from an R-B tree and add it back then, how...
The tree is an example of 
Which type of traversal of binary search tree outputs the value in...
If we first delete a key from 2-3 tree and then add it back then, how...
A 2-3 is a tree such that ...
The rotation need to be done is
The following are the case of ...................in red black Tree
For a 2 -3 Tree which of the following is true
Suppose a binary tree is constructed with n nodes, such that each node...
The height of a BST is given as h. Consider the height of the tree as...
If n numbers are to be sorted in ascending order in O(nlogn) time,...
The run time for traversing all the nodes of a binary search tree with...
Suppose we have numbers between 1 and 1000 in a binary search tree and...
Which of the following trees have height as O(lgn) where number of...
A binary search tree is generated by inserting in order the following...
Alert!

Advertisement