Question
A Java method isLeaf(TreeNode node) is intended to check if a given node is a leaf in a binary tree. class TreeNode { int val; TreeNode left, right; TreeNode(int
A Java method isLeaf(TreeNode node) is intended to check if a given node is a leaf in a binary tree. class TreeNode { int val; TreeNode left, right; TreeNode(int
x) { val = x; } } public boolean isLeaf(TreeNode node) { if (node == null) { return false; } return node.left == null || node.right == null; // Potential bug here } If isLeaf is called on a node that has a left child but no right child, what will the method return?
More IT Operating System Questions
- Which of the following uses Latent Dirichlet Allocation (LDA)?
- State true or false This scheduling algorithm is not ideal for time sharing systems.
- The precision is composed of which of the following two characteristics?
- What does ETL stand for in analytics?
- What is the cardinality of the set {1,2,3,5,4} ?
- State True or False Kernel level thread cannot share the code segment.
- Which of the following is NOT a data transformation activity?
- In a Resource Allocation Graph with single-instance resources, a cycle P1→R1→P2→R2→P1 exists. What does this indicate?
- What is the primary difference between an abstract class and an interface in Java regarding abstraction?
- Consider the following C code: #include #include int main() { char str1[] = "Hello"; char str2[] = {'W', 'o', 'r', 'l', 'd', '\0', 'X'};...
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)