ADP interview question

coding round - it's about tree traversal