# Algorithm multiple choice questions part-4

## Algorithm MCQs:-

1. What is a tree data structure? a) A linear data structure b) A hierarchical data structure c) A non-linear data structure d) Both b and c

Answer: d) Both b and c

1. Which of the following is a depth-first traversal method in a tree? a) Breadth-first b) Inorder c) Topological sort d) None of the above

1. What is the property of a binary search tree? a) The left subtree contains only nodes with keys greater than the node's key b) The right subtree contains only nodes with keys less than the node's key c) The left and right subtrees each must be a binary search tree d) Both b and c

Answer: d) Both b and c

1. Which of the following is a self-balancing binary search tree? a) AVL tree b) B-Tree c) Both a and b d) None of the above

Answer: c) Both a and b

1. What is the maximum number of children that a node can have in a binary tree? a) 1 b) 2 c) 3 d) There is no limit

1. Which traversal method visits the root node first, then the left subtree and finally the right subtree? a) Inorder b) Preorder c) Postorder d) Level order

1. What is the difference between a binary tree and a binary search tree? a) A binary tree can have duplicate nodes, while a binary search tree cannot. b) A binary tree can have any arrangement of its nodes, while a binary search tree must follow a specific property. c) Both a and b d) None of the above

Answer: b) A binary tree can have any arrangement of its nodes, while a binary search tree must follow a specific property.

1. Which of the following is a self-balancing search tree used to reduce the number of disk accesses? a) AVL tree b) B-Tree c) Red-Black tree d) None of the above

1. What is the time complexity of insertion in a binary search tree? a) O(1) b) O(n) c) O(log n) d) O(n log n)

1. What is the maximum number of swaps required in a bubble sort to sort an array of n elements? a) Î˜(n) b) Î˜(n2) c) Î˜(n log n) d) Î˜(1)

1. Which traversal method visits the left subtree, then the right subtree, and finally the root node? a) Inorder b) Preorder c) Postorder d) Level order

1. Which data structure is used to implement a binary search tree? a) Array b) Linked List c) Queue d) Stack

1. What is the maximum number of swaps required in an insertion sort to sort an array of n elements? a) Î˜(n) b) Î˜(n2) c) Î˜(n log n) d) Î˜(1)

Pre  ðŸ‘ˆ                                ðŸ‘‰  Next