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
- The kelvin double bridge is used for______
- Which of the following is not one of the four necessary conditions for a deadlock to occur?
- Which password storage technique is considered most secure against rainbow table attacks?
- In a bank's IT governance framework, which statement correctly describes the relationship between a Business Continuity Plan (BCP) and a Disaster Recovery ...
- Binary Search is an efficient searching algorithm that follows the Divide and Conquer approach. What is its time complexity?
- Four processes arrive as follows: P1 (arrival 0, burst 8), P2 (arrival 1, burst 4), P3 (arrival 2, burst 9), P4 (arrival 3, burst 5). Using preemptive Shor...
- What is the fundamental distinction between 'internal fragmentation' and 'external fragmentation' in memory management?
- What does the term "context switching" refer to in an operating system?
- Perform a dry run of Binary Search for target = 29 in the sorted array [2, 12, 15, 17, 27, 29, 45]. What are the values of mid in each iteration until the ...
- Which of these is a key characteristic of SaaS (Software as a Service)?
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)