-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60d04ac
commit 5f6a35f
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Count Non-Leaf Nodes in Tree | ||
## Easy | ||
<div class="problems_problem_content__Xm_eO"><p><span style="font-size:18px">Given a Binary Tree of size <strong>N</strong>, your task is to complete the function <strong>countNonLeafNodes()</strong>, that should return the count of all the non-leaf nodes of the given binary tree.</span></p> | ||
|
||
<p><span style="font-size:18px"><strong>Example:</strong></span></p> | ||
|
||
<pre><span style="font-size:18px"><strong>Input:</strong> | ||
<input alt="Image" src="https://cdncontribute.geeksforgeeks.org/wp-content/uploads/tree121.gif" style="height:156px; width:259px" type="image" fdprocessedid="orzx9f"> | ||
<strong>Output:</strong> | ||
2 | ||
<strong>Explanation:</strong> | ||
Nodes 1 and 2 are the only non leaf nodes.</span> | ||
</pre> | ||
|
||
<p><span style="font-size:18px"><strong>Your Task:</strong><br> | ||
You don't need to take input or print anything. Your task is to <strong>complete </strong>the function <strong>countNonLeafNodes() </strong>that takes <strong>root </strong>as input and returns the number of non leaf nodes in the tree.</span></p> | ||
|
||
<p><span style="font-size:18px"><strong>Expected Time Complexity: </strong>O(N).<br> | ||
<strong>Expected Auxiliary Space: </strong>O(Height of the Tree).</span></p> | ||
|
||
<p><span style="font-size:18px"><strong>Constraints:</strong><br> | ||
1 ≤ Number of nodes ≤ 10<sup>5</sup></span></p> | ||
</div> |