Skip to content

level / depth [terminology]

Terminology

Usage

  • Use level for the collection of nodes or values at one tree depth.
  • Use depth for the numeric distance from the root.
  • Avoid abbreviating depth to dep, which can imply dependency.
  • Keep level_size when freezing the number of nodes in the current BFS layer.
depth += 1
level = []

for _ in range(len(q)):
    node = q.popleft()
    level.append(node.val)