# Leetcode - Count Complete Tree Nodes

https://leetcode.com/problems/count-complete-tree-nodes/

Given a **complete** binary tree, count the number of nodes.

**Note: **

__Definition of a complete binary tree from Wikipedia:__

In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2^{h} nodes inclusive at the last level h.

**Example:**

Input:1 / \ 2 3 / \ / 4 5 6Output:6

/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func countNodes(root *TreeNode) int { return find(root) } func find(node *TreeNode) int { if node == nil { return 0 } return 1 + find(node.Left) + find(node.Right) }

May 31, 2021 04:30:45 AM

All the mathematical solutions are provided here.

Nov 02, 2021 03:08:19 PM

A commitment of appreciation is all together for your sharing. The suspicion you'll contribute extra quality presents on the current page. Much appreciation to you!

Feb 14, 2022 03:25:06 PM

Your violets blog is so amazing readers. [url="https://www.ishadelhi.in]Hot Delhi Escorts[/url] Great job.

Feb 14, 2023 03:01:23 PM

If you are concerned about the 10th Blueprint 2024 and want to check the 10th Exam Pattern 2024, you can go to the official website and obtain the most recent information. The 10th Exam Pattern 2024 announcement will be made available on the official website. 10th Exam Pattern 2024 If there are any more places where you can acquire the 10th Exam Pattern 2024, we will update this post. We have now provided some internet links where you may obtain your 10th Exam Pattern 2024 Board Online.