Computer Sciences > GATE 2025 SET-2 > Trees
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 number of nodes in T that have exactly two children?
A
(n-2)/2
B
(n-1)/2
C
n/2
D
(n+1)/2

Correct : b

We can find an element that is not the largest with just one comparison: take any two elements from the list, compare them, and the smaller one is guaranteed not to be the largest since the other element is larger. Because the integers are distinct, no ties occur. This method works regardless of where the largest element is in the list.

βœ… Final Answer: Option (a) β€” 1.

Reason: The smaller of two compared elements is definitely not the largest, so only one element comparison is needed in the worst case.

Similar Questions

Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root....
#1081 Fill in the Blanks
Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root....
#1081 Fill in the Blanks
Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root....
#1081 Fill in the Blanks

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......