Skip to content

Commit

Permalink
Create README - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
prernagupta2625 committed Apr 22, 2023
1 parent 60d04ac commit 5f6a35f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Count Non-Leaf Nodes in Tree - GFG/README.md
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&nbsp;<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&nbsp;Task:</strong><br>
You don't need to take input or print anything. Your task is to <strong>complete </strong>the function&nbsp;<strong>countNonLeafNodes()&nbsp;</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>

0 comments on commit 5f6a35f

Please sign in to comment.