0% found this document useful (0 votes)
39 views

BSTQuiz

The document contains a series of 25 multiple choice questions about trees and tree-related data structures like binary search trees, heaps, and AVL trees. For each question, the text provides the question, possible answer choices, and feedback indicating whether the answer is correct or incorrect.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

BSTQuiz

The document contains a series of 25 multiple choice questions about trees and tree-related data structures like binary search trees, heaps, and AVL trees. For each question, the text provides the question, possible answer choices, and feedback indicating whether the answer is correct or incorrect.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Question 1

Correct
Mark 1.00 out of 1.00

Flag question

Question text
In a Heap tree
Question 1Select one:

Values in a node is greater than every value in children of it.

Values in a node is greater than every value in left sub tree and smaller than right sub tree.

Both of other conditions applies.


Feedback
The correct answer is: Values in a node is greater than every value in children of it.

Question 2
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Which of following figures is a height-balanced binary tree?

Question 2Select one:

a.

b.
c.

d.

Feedback
Your answer is incorrect.

The correct answer is:


Question 3
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Select the most correct definition of a tree:

Question 3Select one:

(1)

(3)

(2)
Feedback
The correct answer is: (2)

Question 4
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is the result of the breadth first traverse of the binary search tree T, after inserting the
following keys into the tree sequentially (suppose T is empty before insertion):
7, 8, 4, 0, 1, -1, 10, 24
Question 4Select one:

7, 4, 8, 0, 10, -1, 1, 24

24, 10, 8, 7, 4, 1, 0, -1

-1, 0, 1, 4, 7, 8, 10, 24

7, 4, 8, 0, 10, 1, -1, 24
Feedback
The correct answer is: 7, 4, 8, 0, 10, -1, 1, 24

Question 5
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Question 5Select one:

2.

3.

1.

4.
Feedback
The correct answer is: 4.

Question 6
Correct
Mark 1.00 out of 1.00

Flag question
Question text
What does the following function do?
public void func(Node p)
{ if(p==null) return;
func(p.left());
func(p.right());
System.out.println(p.info);
}

Question 6Select one:

a.
Level-order traversal with the tree with root p

b.
Post-order traversal with the tree with root p

c.
In-order traversal with the tree with root p

d.
Pre-order traversal with the tree with root p
Feedback
Your answer is correct.
The correct answer is: Post-order traversal with the tree with root p

Question 7
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Figure below is a height-balanced binary tree (for every node p of T, the heights of the
children of p differ by at most 1). If a node inserted as child of the node R, how many nodes
will become unbalanced?

Question 7Select one:

a.
2

b.
0

c.
1

d.
3
Feedback
Your answer is correct.
The correct answer is: 1

Question 8
Correct
Mark 1.00 out of 1.00

Flag question

Question text
In all binary trees, there are 2i nodes at level i.

Question 8Answer
True
False
Feedback
The correct answer is 'False'.
Question 9
Correct
Mark 1.00 out of 1.00

Flag question

Question text
To implement an AVL tree, a concept balance factor is introduced (bal = height(right)-
height(left). An AVL tree is created using data :{10,90,5,1,8,0,2,9}. What is the balance factor of
the node 10?
Question 9Select one:

-1

2
Feedback
The correct answer is: -1

Question 10
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is the breadth-first traversal of a tree below after deleting the node 6 by copying?

Question 10Select one:

5, 2, 7, 1, 4, 9, 8

2, 5, 7, 1, 4, 9, 8
5, 2, 7, 4, 1, 9, 8

2, 1, 5, 4, 7, 9, 8
Feedback
The correct answer is: 5, 2, 7, 1, 4, 9, 8

Question 11
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is the minimum number of nodes in a nearly complete binary tree with height 4?
(In a tree the height of root is 1, and a binary tree with height h is called nearly
complete if the tree is complete at level d for d = 1, 2, ..., h-1, and the leaves in the last
level are all in the leftmost positions).
Question 11Select one:

8
Feedback
The correct answer is: 8

Question 12
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Given a binary tree below. What is a result ofpre-order traverse?
Question 12Select one:

E, C, H, F, B, D, I, G

B, H, F, C, I, G, D, B

B, C, E, F, H, D, G, I

B, C, E, F, H, D, I, G
Feedback
The correct answer is: B, C, E, F, H, D, G, I

Question 13
Correct
Mark 1.00 out of 1.00

Flag question

Question text
State True or False: "A balanced tree is one whose root has many more left descendents than
right descendants, or vice versa."
Question 13Select one:

True

False
Feedback
The correct answer is: False

Question 14
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Consider the AVL tree below. What is the breadth first traversal of the tree after inserting a node
with value 3?

Question 14Select one:

6, 2, 7, 1, 3, 5, 9, 4

6, 2, 7, 1, 5, 9, 3, 4

6, 2, 7, 1, 4, 9, 3, 5

6, 2, 7, 1, 3, 4, 9, 5
Feedback
The correct answer is: 6, 2, 7, 1, 4, 9, 3, 5

Question 15
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is the complexity of adding an element to the heap?

Question 15Select one:

a.
O(log n)

b.
O( n)
c.
O(nlog n)

d.
O(1)
Feedback
Your answer is correct.
The correct answer is: O(log n)

Question 16
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Select the correct statement.
(Note: full binary tree = proper binary tree = 2-tree)
Question 16Select one:

Every full binary tree is also a complete binary tree.

Every complete binary tree is also a full binary tree.

Every binary tree is either complete or full.

No binary tree is both complete and full.


Feedback
The correct answer is: Every complete binary tree is also a full binary tree.

Question 17
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
The complexity of deleting any arbitrary node value element from heap is

Question 17Select one:


a.
O( n)

b.
O(nlogn)

c.
O(n2)

d.
O(logn)
Feedback
Your answer is incorrect.
The correct answer is: O(logn)

Question 18
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Specify the correct implementation of pre-order traverse algorithm for binary trees.

Question 18Select one:

void preOrder(Node p)
{ if (p == null) { visit(p); preOrder(p.left); preOrder(p.right); }
}

void preOrder(Node p)
{ if (p != null) { visit(p); preOrder(p.left); preOrder(p.right); }
}

void preOrder(Node p)
{ visit(p); preOrder(p.left); preOrder(p.right); }

void preOrder(Node p)
{ if (p != null) { preOrder(p.left); visit(p); preOrder(p.right); }
}
Feedback
The correct answer is: void preOrder(Node p)
{ if (p != null) { visit(p); preOrder(p.left); preOrder(p.right); }
}

Question 19
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Select the correct statement.
Suppose T is a binary tree with 9 nodes. What is the minimum possible height of T?
(Note: In a tree the height of root is 1)
Question 19Select one:

5
Feedback
The correct answer is: 4

Question 20
Correct
Mark 1.00 out of 1.00

Flag question

Question text
State True or False:"In a binary search tree, all the nodes that are left descendants of node A have
key values greater than A; all the nodes that are A's right descendants have key values less than
(or equal to) A."
Question 20Select one:

True

False
Feedback
The correct answer is: False

Question 21
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Select the most correct definition of a binary tree:

Question 21Select one:

(3)

(2)

(1)
Feedback
The correct answer is: (3)

Question 22
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Which of the below diagrams is/are AVL tree/s?

i.

ii.

Question 22Select one:

a.
both I and II

b.
none of the mentioned

c.
only I

d.
only II
Feedback
Your answer is incorrect.
The correct answer is: only II

Question 23
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Specify the correct statement about a binary search tree(select the most suitable one).
Question 23Select one:

For better searching performance, a tree should be in back-bone shape.

It is necessary to build a tree with optimized height to stimulate searching operation.

In a binary search tree, all the nodes that are left descendants of node A have key values
greater than A; all the nodes that are A's right descendants have key values less than (or
equal to) A.

The main purpose of balancing a tree is to keep the tree in good shape.
Feedback
The correct answer is: It is necessary to build a tree with optimized height to stimulate
searching operation.

Question 24
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Consider the following min-heap:

What will be the value in the root after deleting root node (value 1) and rearranging the
heap?

Question 24Select one:

a.
100

b.
3
c.
2

d.
17
Feedback
Your answer is correct.
The correct answer is: 2

Question 25
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Consider the binary tree below. Which statement is correct?
(full binary tree = proper binary tree = 2-tree)

Question 25Select one:

The tree is complete but not full.

The tree is full but not complete.

The tree is neither complete nor full.

The tree is both full and complete.


Feedback
The correct answer is: The tree is full but not complete.
Question 26
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
What is the minimum number of nodes in a full binary tree with height 3?
(In a tree the height of root is 1, and in a full binary tree every node other than the
leaves has two children).

Question 26Select one:

5
Feedback
The correct answer is: 5

Question 27
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A binary tree is balanced if the difference between left and right subtree of every node is
not more than ____

Question 27Select one:

a.
3

b.
2
c.
1

d.
0
Feedback
Your answer is correct.
The correct answer is: 1

Question 28
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Heap can be used as ________________

Question 28Select one:

a.
Priority queue

b.
None of the mentioned

c.
Stack

d.
A decreasing order array
Feedback
Your answer is correct.
The correct answer is: Priority queue

Question 29
Correct
Mark 1.00 out of 1.00

Flag question
Question text
Specify the correct implementation of in-order traverse algorithm for binary trees.

Question 29Select one:

void inOrder(Node p)
{ inOrder(p.left); visit(p); inOrder(p.right); }

void inOrder(Node p)
{ if (p != null) { inOrder(p.left); visit(p); inOrder(p.right); }
}

void inOrder(Node p)
{ if (p != null) { visit(p); inOrder(p.left); inOrder(p.right); }
}

void inOrder(Node p)
{ if (p == null) { inOrder(p.left); visit(p); inOrder(p.right); }
}
Feedback
The correct answer is: void inOrder(Node p)
{ if (p != null) { inOrder(p.left); visit(p); inOrder(p.right); }
}

Question 30
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Question 30Select one:

2.

4.

1.

3.
Feedback
The correct answer is: 2.

Question 31
Correct
Mark 1.00 out of 1.00

Flag question

Question text
In a max-heap, element with the greatest key is always in the which node?

Question 31Select one:

a.
First node of right sub tree
b.
First node of left sub tree

c.
Leaf node

d.
root node
Feedback
Your answer is correct.
The correct answer is: root node

Question 32
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Consider the binary tree below. Which statement is correct?
(full binary tree = proper binary tree = 2-tree)

Question 32Select one:

The tree is both full and complete.

The tree is complete but not full.

The tree is neither complete nor full.

The tree is full but not complete.


Feedback
The correct answer is: The tree is neither complete nor full.

Question 33
Correct
Mark 1.00 out of 1.00

Flag question

Question text

Question 33Select one:

12

41

15

16
Feedback
The correct answer is: 15

Question 34
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Balanced binary tree with n items allows the lookup of an item in ____ worst-case time.

Question 34Select one:

a.
O(log n)

b.
O(1)

c.
O(nlog 2)

d.
O( n)
Feedback
Your answer is correct.
The correct answer is: O(log n)

Question 35
Correct
Mark 1.00 out of 1.00

Flag question

Question text
The in-order traverse of tree will yield a sorted listing of elements of tree in
Question 35Select one:

Binary search trees

None of others
Binary trees

Heaps
Feedback
The correct answer is: Binary search trees

You might also like