- Root goroutines: 3 (root-0, root-1, root-2)
- Children per node: 3
- Maximum depth: 3
3 Roots (root-0, root-1, root-2)
│
├─→ Each spawns 3 children = 9 total at Depth 1
│ │
│ ├─→ Each spawns 3 children = 27 total at Depth 2
│ │ │
│ │ ├─→ Each spawns 3 children = 81 total at Depth 3
│ │ │ │
│ │ │ └─→ 81 Leaf nodes (no further spawning)
Tree:
- 3 roots (root-0, root-1, root-2) - each follows the same branching pattern
- 9 goroutines spawned at depth 1 (3 roots × 3 children each)
- 27 goroutines spawned at depth 2 (9 parents × 3 children each)
- 81 goroutines spawned at depth 3 (27 parents × 3 children each)
- 81 leaf nodes at depth 3 (these don't spawn any children)
So Total = 9 + 27 + 81 = 117 goroutines spawned
go run main.goThe program will show each goroutine starting, spawning children, and completing. At the end, it displays the total number of goroutines spawned.