TomoLink
TCS NQT GuideTCS NQT Programming Logic & CS FundamentalsData Structures: Binary Trees and Heaps Basics

Data Structures: Binary Trees and Heaps Basics

Learn core concepts, essential formulas, and attempt practice questions designed on the latest TCS NQT testing patterns.

Key Concepts & Formulas

  • 1Binary Tree: Each node has at most 2 children.
  • 2Binary Search Tree (BST): Left child < Parent < Right child.
  • 3Max Heap: Parent value is greater than or equal to child values.

TCS NQT Style Practice Questions

Practice Question 1

Inorder traversal of a Binary Search Tree output is:

A) Sorted in ascending order
B) Sorted in descending order
C) Unsorted
D) Alternating order

Correct Answer: A) Sorted in ascending order

Step-by-step Solution: Inorder traversal visits Left -> Root -> Right. For a BST, this yields values in sorted ascending order.

Practice Question 2

What is the maximum number of nodes at level 'L' of a binary tree?

A) 2^L
B) 2^(L-1)
C) L^2
D) 2L

Correct Answer: A) 2^L

Step-by-step Solution: Level 0 has 1 node (2^0), Level 1 has 2 nodes (2^1). Level L has 2^L nodes.

Study Pro-Tip

Draw tree representations on scrap paper to trace path traversal logic.