12 Lecture
CS301
Midterm & Final Term Short Notes
Operations on Binary Tree
Operations on Binary Tree include inserting a node, deleting a node, searching for a node, traversing the tree in different orders (pre-order, in-order, post-order), finding the height of the tree, checking if the tree is balanced, and more. The
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
- 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 method visits the nodes in the order left subtree, root, right subtree? a) Pre-order traversal b) In-order traversal c) Post-order traversal d) Level-order traversal
Answer: b) In-order traversal
- Which traversal method visits the nodes in the order root, left subtree, right subtree? a) Pre-order traversal b) In-order traversal c) Post-order traversal d) Level-order traversal
Answer: a) Pre-order traversal
- What is the time complexity of searching for a node in a Binary Tree? a) O(1) b) O(log n) c) O(n) d) It depends on the implementation
Answer: c) O(n)
- What is the maximum number of nodes at level k in a Binary Tree? a) 2^k b) k^2 c) k+1 d) None of the above
Answer: a) 2^k
- Which of the following is a way to delete a node in a Binary Tree? a) Deleting the node and its children b) Replacing the node with its left child c) Replacing the node with its right child d) All of the above
Answer: d) All of the above
- What is the time complexity of finding the height of a Binary Tree? a) O(1) b) O(log n) c) O(n) d) It depends on the implementation
Answer: c) O(n)
- What is the maximum number of nodes in a Binary Tree with height h? a) 2^h b) h^2 c) h+1 d) None of the above
Answer: a) 2^h - 1
- Which of the following is a way to insert a node in a Binary Tree? a) As the left child of a leaf node b) As the right child of a leaf node c) As the left child of a non-leaf node d) All of the above
Answer: d) All of the above
- Which of the following is an advantage of using a Binary Tree over a linked list? a) Binary Tree can be searched faster than a linked list b) Binary Tree can be sorted faster than a linked list c) Binary Tree can store data in a hierarchical structure d) All of the above
Answer: d) All of the above
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
- What is a binary tree?
Answer: A binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child.
- What is the height of a binary tree?
Answer: The height of a binary tree is the length of the longest path from the root node to a leaf node.
- What is the difference between a binary tree and a binary search tree?
Answer: A binary search tree is a binary tree with the property that the value of each node is greater than or equal to the values in its left subtree and less than or equal to the values in its right subtree.
- What is the time complexity of inserting a node in a binary tree?
Answer: The time complexity of inserting a node in a binary tree is O(h), where h is the height of the tree.
- What is the time complexity of deleting a node in a binary tree?
Answer: The time complexity of deleting a node in a binary tree is O(h), where h is the height of the tree.
- What is the difference between pre-order traversal and post-order traversal?
Answer: Pre-order traversal visits the root node first, followed by the left subtree and then the right subtree, while post-order traversal visits the left subtree first, followed by the right subtree and then the root node.
- How do you determine if a binary tree is balanced?
Answer: A binary tree is balanced if the height of its left subtree and the height of its right subtree differ by at most one.
- What is the difference between complete binary tree and a full binary tree?
Answer: A complete binary tree is a binary tree in which every level except possibly the last is completely filled, while a full binary tree is a binary tree in which every node has either two children or zero children.
- What is the time complexity of finding the maximum element in a binary tree?
Answer: The time complexity of finding the maximum element in a binary tree is O(n), where n is the number of nodes in the tree.
- What is the time complexity of finding the height of a binary tree using dynamic programming?
Answer: The time complexity of finding the height of a binary tree using dynamic programming is O(n), where n is the number of nodes in the tree.