So I'm currently practicing DFS & BFS approaches to binary trees and I am confused on how multiple arguments are being passed into the .append
statements below. I know that .append
can only take one argument and that when the the arguments are encapsulated in parenthesis they are treated as so, but what does it mean when you encapsulate them?
class Solution:
def maxDepth(self, root):
"""
:type root: TreeNode
:rtype: int
"""
stack = []
if root is not None:
stack.append((1, root)) # <---- Here
depth = 0
while stack != []:
current_depth, root = stack.pop()
if root is not None:
depth = max(depth, current_depth)
stack.append((current_depth + 1, root.left)) # <---- Here
stack.append((current_depth + 1, root.right)) # <---- Here
return depth
To reiterate, what does .append((arg1, arg2))
mean? How are those args
treated and what logic is behind it?