Binary trees MCQs

By: Prof. Dr. Fazal Rehman Shamil | Last updated: September 20, 2024

What is a binary tree?

a) A tree with at most 2 children for each node
b) A tree where each node has exactly 2 children
c) A tree with an arbitrary number of children for each node
d) A tree where nodes are arranged in a binary search order
Answer: a) A tree with at most 2 children for each node
Which of the following statements is true about binary trees?

a) Each node has exactly one child
b) Each node has at most two children
c) Each node has an unlimited number of children
d) Each node has exactly three children
Answer: b) Each node has at most two children
What is a binary search tree (BST)?

a) A binary tree where the left child is greater than the parent and the right child is less than the parent
b) A binary tree where the left child is less than the parent and the right child is greater than the parent
c) A binary tree where the left child is equal to the parent and the right child is not equal to the parent
d) A binary tree where the left child is less than or equal to the parent and the right child is greater than or equal to the parent
Answer: b) A binary tree where the left child is less than the parent and the right child is greater than the parent
What is the minimum number of nodes in a binary tree of height 3?

a) 4
b) 5
c) 6
d) 7
Answer: a) 4
What is the maximum number of nodes in a binary tree of height 4?

a) 8
b) 15
c) 16
d) 31
Answer: d) 31
Which traversal visits the nodes in the order: left subtree, root, right subtree?

a) Preorder
b) Inorder
c) Postorder
d) Level order
Answer: b) Inorder
In a binary tree, if a node has no children, it is called a:

a) Leaf node
b) Root node
c) Internal node
d) Sibling node
Answer: a) Leaf node
Which traversal visits the root node first, then the left subtree, and finally the right subtree?

a) Preorder
b) Inorder
c) Postorder
d) Level order
Answer: a) Preorder
Which of the following operations can be efficiently implemented using a binary search tree?

a) Finding the maximum element
b) Finding the minimum element
c) Finding the median element
d) Finding the nth smallest element
Answer: d) Finding the nth smallest element
Which traversal visits the nodes in the order: left subtree, right subtree, root?

a) Preorder
b) Inorder
c) Postorder
d) Level order
Answer: c) Postorder
What is the time complexity of searching for an element in a balanced binary search tree?

a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: b) O(log n)
Which of the following operations requires the worst-case time complexity in a binary search tree?

a) Insertion
b) Deletion
c) Searching
d) Traversal
Answer: b) Deletion
What is the height of a binary tree with only one node?

a) 0
b) 1
c) 2
d) Undefined
Answer: a) 0
Which traversal is used to create a copy of a binary tree?

a) Preorder
b) Inorder
c) Postorder
d) Level order
Answer: a) Preorder
In a binary tree, what is the maximum number of nodes at level 3?

a) 4
b) 7
c) 8
d) 15
Answer: c) 8
Which traversal can be used to evaluate postfix expressions?

a) Preorder
b) Inorder
c) Postorder
d) Level order
Answer: c) Postorder
Which traversal is commonly used to sort elements in a binary search tree in ascending order?

a) Preorder
b) Inorder
c) Postorder
d) Level order
Answer: b) Inorder
Which of the following is NOT a valid binary tree traversal?

a) Left-root-right
b) Root-left-right
c) Right-root-left
d) Left-right-root
Answer: c) Right-root-left
What is the maximum number of leaf nodes in a binary tree with 15 nodes?

a) 7
b) 8
c) 15
d) 16
Answer: b) 8
Which traversal visits all the levels of nodes in order from top to bottom, left to right?

a) Preorder
b) Inorder
c) Postorder
d) Level order
Answer: d) Level order

 

Data Structures MCQs

Basic Concepts

  1. Introduction to Data Structures
  2. Complexity Analysis MCQs

Linear Data Structures MCQs

  1. Arrays MCQs
  2. Linked Lists MCQs
  3. Stacks MCQs
  4. Queues MCQs

Non-Linear Data Structures MCQs

  1. Trees MCQs
  2. Heaps MCQs
  3. Graphs MCQs

Hashing MCQs MCQs

  1. Hash Tables

Sorting and Searching Algorithms MCQs 

  1. Sorting Algorithms MCQs
  2. Searching Algorithms MCQs

Miscellaneous

  1. Memory Management in data structures MCQs
  2. String Manipulation Algorithms MCQs
  1. Data Structures MCQs 1
  2. Data Structures MCQs 2
  3. Data Structures MCQs 3
  4. Data Structures MCQs 4
  5. Data Structures MCQs 5
  6. Stacks Solved MCQs
  7. Queues MCQs
  8. pointer mcqs
  9. Array MCQs