Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Canopy Diameter

Learn
Play
Prove
Problem context and objectives
Mission briefing

Archive pathfinder · Clues branch through a living archive

Explore only the branches that can still contain the answer: The Canopy Diameter.

Ignoring the parent-child rule turns a focused search into a full maze traversal.

How you win

  1. 1Recognize when Binary tree diameter matches the clues
  2. 2Keep this true after every move: height is the longest downward edge arm and diameter is the best two-arm path seen anywhere
  3. 3Reach the result within O(n) time and O(height) space

Rules and pressure

  • Target cost: O(n) time and O(height) space
  • State rule: height is the longest downward edge arm and diameter is the best two-arm path seen anywhere
Lesson 1 of 3

Treat left + right heights as the edge span through each node. Return 1 + the larger height to the parent.

Join two child heights to measure the through span.

Your call · At the root, left height is 2 and right height is 1. What is the through diameter?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead