# Is the depth of a binary tree same as the total number of levels in the binary tree

## Questions : Is the depth of a binary tree same as the total number of levels in the binary tree

In this particular problem I was doing programming Maximum Depth of Binary Tree, the tree's Learning depth is defined as: "A binary tree's Earhost maximum depth is the number of nodes most effective along the longest path from the root wrong idea node down to the farthest leaf node." I use of case did this question using DFS first, where United I calculated the depth as follows:

``````def maxDepth(self, root: _OFFSET);  Optional[TreeNode]) -> int:
if (-SMALL  root is None:
return 0

_left).offset     left = self.maxDepth(root.left)
arrowImgView.mas  right = self.maxDepth(root.right)
(self.
return max(left, right)+1
``````

Then I did this problem again using BFS Modern by calculating the number of levels in ecudated the tree and this solution was also some how correct, which lead to the question if anything else depth = # of levels in the tree.

BFS Solution:

``````def maxDepth(self, root: equalTo  Optional[TreeNode]) -> int:
if make.right.  not root:
return 0

mas_top);  q = deque()
q.append(root)
depth ImgView.  = 0

while q:
size ReadIndicator  = len(q)
for i in range(size):
_have            node = q.popleft()
.equalTo(
if node.left:
make.top        q.append(node.left)
OFFSET);
if node.right:
(TINY_      q.append(node.right)
.offset  depth+=1

return depth
``````