MCQ Bank
See the below code and fill the appropriate answer for ? sign.
void fastInorder(TreeNode* p)
{
while((p=nexInorder(p)) != ? )
cout << p->getInfo();
}
- A) RTH
- B) LTH
- C) dummy
- D) rootNode
Which of the following method is helpful in creating the heap at once?
- A) insert
- B) update
- C) add
- D) percolateDown
Which of the following statement is NOT true about threaded binary tree?
- A) Left thread of the right-most node points to the dummy node.
- B) The left pointer of dummy node points to the root node of the tree.
- C) Right thread of the right-most node points to the dummy node.
- D) Left thread of the left-most node points to the dummy node.
It is necessary for Huffman encoding tree to be,
- A) Complete Binary Tree
- B) Binary Search Tree
- C) None of the given
- D) Binary Tree
In threaded binary tree, we convert the ________ pointers of binary tree to threads.
- A) Left
- B) None of the given options
- C) NULL
- D) Right
A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its __________ successor
- A) Inorder
- B) Postorder
- C) levelorder
- D) Preorder
A binary tree with N internal nodes has _____ links, _______ links to internal nodes and ________ links to external nodes.
- A) 2N, N-1, N+1
- B) N-1, 2N, N+1
- C) N+1, 2N, N-1
- D) N+1, N-1, 2N
Consider a min heap, represented by the following array: 2,5,6,7,8 After calling the function deleteMin().Which of the following is the updated min heap?
- A) 5,6,7,8
- B) 5,7,8,6
- C) 5,8,6,7
- D) 5,7,6,8
When a complete binary tree, represented by an array then for any array element at position i, the left child is at position ______.
- A) 2i
- B) 2i+1
- C) 2i-1
- D) floor(i/2)
If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT a ----------
- A) Threaded binary tree
- B) Expression tree
- C) Perfectly complete Binary tree
- D) Complete Binary tree
We are given N items to build a heap of items , this can be done with _____ successive inserts.
- A) N
- B) N^2
- C) N-1
- D) N+1
Which one of the following array elements represents a min heap?
- A) 9,11,13,10,15,18
- B) 9,11,13,26,15,18
- C) 9,7,13,26,15,18
- D) 9,11,8,26,15,18
A complete binary tree of height 3 has between ________ nodes.
- A) 8 to 17
- B) 8 to 14
- C) 8 to 16
- D) 8 to 15
In heap's percolateDown method, why do we start our iterations from n/2 instead of n?
- A) Because nth node is a leaf node and it doesn't have any left & right child to get sorted
- B) nth node contains null
- C) nth node key is always largest
- D) Because n node iterations create complexity
While building Huffman encoding tree the parent node is _________ of left and right child nodes.
- A) Multiplication
- B) Division
- C) Subtraction
- D) Addition
We implement the heap by ______________ .
- A) Expression tree
- B) AVL tree
- C) Complete binary tree
- D) Threaded Tree
Which of the following heap method lowers the value of key at position ‘p’ by the amount ‘delta’?
- A) remove(p,delta)
- B) percolateDown(p,delta)
- C) increaseKey(p,delta)
- D) decreaseKey(p,delta)
In building Huffman encoding tree from leaf nodes,
- A) we start with characters with least frequencies.
- B) we start with characters with maximum frequencies.
- C) none of the options.
- D) we start with characters with medium frequencies.
In heap, insertion takes unit time if _________________.
- A) Insertion is done at leaf node
- B) Key percolates up to the root
- C) Insertion is done at level 2
- D) Insertion is done at level 1
While building Huffman encoding tree the new node that is the result of joining two nodes has the frequency.
- A) Equal to the difference of the two frequencies
- B) Equal to the greater frequency
- C) Equal to the small frequency
- D) Equal to the sum of the two frequencies