Back to problems

Burning a Binary Tree (Time to Burn Entire Tree)

Algorithm · Tesla · Medium

A binary tree has one of its nodes ignited at time t = 0. During each subsequent time unit, flames move from every burning node to any directly connected node: its parent, left child, or right child. Determine how long it takes before every node in the tree is burning. Equivalently, find the greatest number of time steps required for the fire to reach any node. Each value stored in the tree is distinct. You are given both the tree representation and the value of the node…

Checking your access…