(A) Maintain sizes (number of nodes) of all trees, and during union
(B) Make smaller tree, the subtree of the larger one
(C) Make the larger tree, the subtree of the smaller one
(D) Implementation: for each root node i, instead of setting parent[i] to -1, set it to -k if tree rooted at i has k nodes
Tag: Data Structures Mcqs
In threaded binary tree the NULL pointers are replaced by?
(A) Preorder successor or predecessor
(B) Inorder successor or predecessor
(C) Postorder successor or predecessor
(D) NULL pointers are not replaced
Which of the following is not true regarding the maze generation?
(A) Randomly remove walls until the entrance and exit cells are in the same set
(B) Removing a wall is the same as doing a union operation
(C) Remove a randomly chosen wall if the cells it separates are already in the same set
(D) Do not remove a randomly chosen wall if the cells it separates are already in the same set
Which of the following statement is NOT correct about find operation:
(A) It is not a requirement that a find operation returns any specific name, just that finds on two elements return the same answer if and only if they are in the same set
(B) One idea might be to use a tree to represent each set, since each element in a tree has the same root, thus the root can be used to name the set
(C) Initially each set contains one element
(D) Initially each set contains one element and it does not make sense to make a tree of one node only
Which formula is the best approximation for the depth of a heap with n nodes?
(A) log (base 2) of n
(B) The number of digits in n (base 10), e.g., 145 has three digits
(C) The square root of n
(D) n
For a perfect binary tree of height h, having N nodes, the sum of heights of nodes is?
(A) N – (h – 1)
(B) N – (h + 1)
(C) N – 1
(D) N – 1 + h
Which of the following statement is true about dummy node of threaded binary tree?
(A) This dummy node never has a value
(B) This dummy node has always some dummy value
(C) This dummy node has either no value or some dummy value
(D) This dummy node has always some integer value
By using __ we avoid the recursive method of traversing a Tree, which makes use of stacks and consumes a lot of memory and time.
(A) Binary tree only
(B) Threaded binary tree
(C) Heap data structure
(D) Huffman encoding