The GATE Grind

GATE Programming and Data Structures: Trees and Binary Search Trees – Previous Year Questions

20 GATE previous year questions on Trees and Binary Search Trees (Programming and Data Structures, Computer Science) with answers and explanations, from every paper.

  1. GATE 2017 CS Q16 (1 mark, Multiple choice) – Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights of T are: Note: The height of a tree with a single node is 0.
  2. GATE 2015 CS Q15 (1 mark, Multiple choice) – The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are
  3. GATE 2015 CS Q17 (1 mark, Multiple choice) – Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)? I. 3, 5, 7, 8, 15, 19, 25 II. 5, 8, 9, 12, 10, 15, 25…
  4. GATE 2015 CS Q35 (1 mark, Multiple choice) – What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
  5. GATE 2018 CS Q30 (1 mark, Numerical answer) – The postorder traversal of a binary tree is 8,9,6,7,4,5,2,3,1. The inorder traversal of the same tree is 8,6,9,4,7,2,5,1,3. The height of a tree is…
  6. GATE 2026 CS (CS2) Q12 (1 mark, Multiple choice) – The set T represents various traversals over a binary tree. The set S represents the order of visiting nodes during a traversal. I: Inorder II:…
  7. GATE 2026 CS (CS2) Q49 (2 marks, Multiple select) – Consider a binary search tree (BST) with n leaf nodes, where n>0. All keys are distinct real numbers. For a node V, let Suc(V) denote its inorder…
  8. GATE 2026 CS (CS1) Q33 (1 mark, Numerical answer) – The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full…
  9. GATE 2026 CS (CS1) Q40 (2 marks, Multiple choice) – Let P be the set of all integers from 1 to 15. Consider any order of insertion of the elements of P into a binary search tree that creates a complete…
  10. GATE 2026 CS (CS1) Q62 (2 marks, Numerical answer) – The following sequence corresponds to the preorder traversal of a binary search tree T: 50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77 The position of the…
  11. GATE 2025 CS (CS2) Q13 (1 mark, Multiple choice) – Consider a binary tree T in which every node has either zero or two children. Let n > 0 be the number of nodes in T. Which ONE of the following is the…
  12. GATE 2025 CS (CS2) Q35 (1 mark, Numerical answer) – Suppose the values 10, -4, 15, 30, 20, 5, 60, 19 are inserted in that order into an initially empty binary search tree. Let T be the resulting binary…
  13. GATE 2025 CS (CS2) Q38 (2 marks, Multiple choice) – A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data…
  14. GATE 2025 CS (CS1) Q26 (1 mark, Multiple select) – Which of the following statement(s) is/are TRUE for any binary search tree (BST) having n distinct integers?
  15. GATE 2024 CS (CS2) Q39 (2 marks, Multiple choice) – You are given a set V of distinct integers. A binary search tree T is created by inserting all elements of V one by one, starting with an empty tree.…
  16. GATE 2023 CS Q47 (2 marks, Multiple choice) – Consider the C function foo and the binary tree shown. [Figure: binary tree with root 10; left child 5 with children 3 and 8; right child 11 with…
  17. GATE 2021 CS Q20 (1 mark, Multiple choice) – A binary search tree T contains n distinct elements. What is the time complexity of picking an element in T that is smaller than the maximum element…
  18. GATE 2020 CS Q15 (1 mark, Multiple choice) – The preorder traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?
  19. GATE 2020 CS Q16 (1 mark, Multiple choice) – What is the worst case time complexity of inserting n2 elements into an AVL-tree with n elements initially?
  20. GATE 2020 CS Q51 (2 marks, Multiple choice) – In a balanced binary search tree with n elements, what is the worst case time complexity of reporting all elements in range [a,b]? Assume that the…