## Question 1 How does BFS ensure that it visits all nodes in a binary tree while traversing level by level? ### Options 1. By using a stack data structure to keep track of visited nodes Incorrect ---------------------------- 2. By using a queue data structure to maintain the order of node exploration Correct BFS ensures level-wise traversal with a queue data structure. ---------------------------- 3. By recursively traversing the left and right subtrees in a depth-first manner Incorrect ---------------------------- 4. By randomizing the order of node exploration for better coverage Incorrect ---------------------------- --------------------------------------------- ## Question 2 What is the output if the following tree is given as input? ```text ___ 50 _ | | -50 _ 200 | __ 32 | __ 12 | -1 ### Options 1. 50, -50 : 200, 32, 12, -1 Incorrect Although this is the correct order of nodes, the levels are not separated by the correct separator. ---------------------------- 2. 50 : -50, 200 : 32 : 12 : -1 Correct Moving down the tree, level by level, this is the correct order of nodes. ---------------------------- 3. -1 : 12 : 32 : -50, 200 : 50 Incorrect ---------------------------- --------------------------------------------- ## Question 3 What is the output if the following tree is given as input? ```text __ 50 _ | | __ 20 60 _ | | _ 10 70 _ | | 5 80 _ | 90 ### Options 1. 50 : 20, 60 : 10, 70 : 5, 80 : 90 Correct This is the correct order of nodes as we move down the tree, level by level. ---------------------------- 2. 50, 20 : 60, 10 : 70, 5 : 80, 90 Incorrect Although this is the correct order of nodes, the levels are not separated by the correct separator. ---------------------------- 3. 90 : 5, 80 : 10, 70 : 20, 60 : 50 Incorrect ---------------------------- ---------------------------------------------