Your concept feed

24 ideas

A few small steps. No rush.

Follow the connections in this topic

Let’s picture it

Count a tiny family of dots.

Parent
Child: 1
Child: 1

One parent has two children. Each child says, “There’s one of me.”

Swipe when you’re ready
One little change

Let the answers travel up.

Total: 3
1
1

The parent adds the two answers, then counts itself: 1 + 1 + 1.

Same idea. One more small step.
Now it has a name

That works for bigger trees too.

my answer
left answer
right answer

Ask each child about its little tree. Combine the answers. You don’t need to hold the whole tree in your head.

Want to try a tiny question?
No pressure. Just try it.

Do we also count the parent itself?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Open a box.

Big box
Small box
Empty

There’s a smaller box inside. We already know how to open a box.

1 / 3
Let’s picture it

How far down is this dot?

Level 0
Level 1
Level 1

Call the top dot level 0. Its children sit one level below.

Swipe when you’re ready
One little change

Send a little note downward.

My level: 1
Your level: 2
Your level: 2

Tell each child: “Your level is my level plus one.”

Same idea. One more small step.
Now it has a name

Some answers need the parent’s help.

send level ↓
child
child

A child can count its descendants. But its distance from the top needs information from above.

Want to try a tiny question?
No pressure. Just try it.

Can a leaf tell its level just by seeing no children?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Count a tiny family of dots.

Parent
Child: 1
Child: 1

One parent has two children. Each child says, “There’s one of me.”

1 / 3
Let’s picture it

Two trees can make different promises.

8
3
10

In a search tree, smaller keys go left and larger keys go right. We’ll use distinct keys here.

Swipe when you’re ready
One little change

A heap promises something else.

3
10
8

A min-heap keeps the smallest value at the top. Its left and right sides need not be sorted.

Same idea. One more small step.
Now it has a name

Choose the promise you need.

find a key
take smallest

Looking for an ordered key? Think search tree. Repeatedly taking the smallest? Think min-heap.

Want to try a tiny question?
No pressure. Just try it.

Does a min-heap promise its left side is smaller than its right?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Find 8 in a sorted row.

2
4
6
8
10

Start with 2, 4, 6, 8, 10. Look at the middle: 6.

1 / 3
Let’s picture it

Visit the same three dots.

A
B
C

We can say the parent’s name first, then visit its children.

Swipe when you’re ready
One little change

Or wait until the children finish.

Finish last: A
First: B
Then: C

For a count, the parent needs the children’s answers first. So visit B, C, then finish A.

Same idea. One more small step.
Now it has a name

The timing has a name.

before
between
after

Parent first is preorder. Children first is postorder. Left, parent, right is inorder for a binary tree.

Want to try a tiny question?
No pressure. Just try it.

Which timing helps combine child answers?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Count a tiny family of dots.

Parent
Child: 1
Child: 1

One parent has two children. Each child says, “There’s one of me.”

1 / 3
Let’s picture it

A grandparent’s rule still counts.

8
3
10

Everything in 8’s left subtree must stay below 8, not just its immediate child.

Swipe when you’re ready
One little change

A local check can miss trouble.

8 → left
3 → right
9: too big

Put 9 to the right of 3, but still inside 8’s left subtree. It passes 3’s rule and breaks 8’s.

Same idea. One more small step.
Now it has a name

Carry the allowed range.

below 8
above 3
3 < key < 8

Pass down the lower and upper limits from ancestors. Each node must fit all the rules that brought us here.

Want to try a tiny question?
No pressure. Just try it.

Is checking only a node and its immediate children enough?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Two trees can make different promises.

8
3
10

In a search tree, smaller keys go left and larger keys go right. We’ll use distinct keys here.

1 / 3
Let’s picture it

Walk upward from two dots.

A
B
C

B and C have the same parent, A. Their upward paths meet there.

Swipe when you’re ready
One little change

Find the first meeting place.

Meet here: A
B ↑
C ↑

We want the lowest shared ancestor, not an older ancestor farther up.

Same idea. One more small step.
Now it has a name

Let the children report what they found.

two sides meet
found B
found C

If the two targets are found on different sides, this parent is their meeting place. Assume both targets exist.

Want to try a tiny question?
No pressure. Just try it.

Could one target itself be the shared ancestor?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Count a tiny family of dots.

Parent
Child: 1
Child: 1

One parent has two children. Each child says, “There’s one of me.”

1 / 3
A familiar idea

Walking upward one parent at a time works.

node
parent
grandparent

But thousands of ancestor queries can repeat the same long climbs. Let’s save shortcuts.

Swipe when you’re ready
One new wrinkle

Save jumps that double.

2 links
2 links
4 links

For every node, remember its ancestor 1, 2, 4, 8… links above. Two 2-link jumps make one 4-link jump.

Same idea. One more small step.
Try a tiny example

Six links become four plus two.

start
up 4
up 2

To climb six parents, take one saved four-link jump, then one saved two-link jump.

Same idea. One more small step.
Notice what matters

Build the next row from the previous.

half jump
half jump
double jump

up[j][v] is the 2ʲ-th ancestor. Its value is up[j−1][up[j−1][v]], unless that intermediate ancestor is missing.

Same idea. One more small step.
Make it reusable

This is binary lifting.

prepare once
answer many

Precompute a table once. Queries combine logarithmically many jumps. The same shortcuts also speed up repeated lowest-common-ancestor queries.

Want to try a tiny question?
No pressure. Just try it.

What should happen when a jump would pass above the root?

You can also keep scrolling
1 / 6
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Walk upward from two dots.

A
B
C

B and C have the same parent, A. Their upward paths meet there.

1 / 3
Let’s picture it

Join the two longest arms.

A
B
C

A path through A can come from B and leave toward C.

Swipe when you’re ready
One little change

But send only one arm upward.

send one ↑
left arm
right arm

To extend this path to A’s parent, choose one side. Taking both would create a fork, not a path.

Same idea. One more small step.
Now it has a name

Keep two different answers.

return one arm
compare two arms

Return one extendable arm. Separately remember the best complete path seen anywhere. That longest path is the tree’s diameter.

Want to try a tiny question?
No pressure. Just try it.

Can a simple path use three arms at one node?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Count a tiny family of dots.

Parent
Child: 1
Child: 1

One parent has two children. Each child says, “There’s one of me.”

1 / 3
Let’s picture it

BST order does not guarantee small height.

1
2
3

Inserting 1,2,3 into an ordinary BST creates a chain. Search becomes linear.

Swipe when you’re ready
One little change

Store a height summary.

left height
right height
balance

After each insertion, recompute height and compare left versus right. Difference beyond one means this node is unbalanced.

Same idea. One more small step.
Now it has a name

Rotate without breaking order.

2 root
1 left
3 right

For 1→2→3, rotate left at 1. Node 2 becomes the root with 1 left and 3 right.

Want to try a tiny question?
No pressure. Just try it.

What does a rotation preserve?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Two trees can make different promises.

8
3
10

In a search tree, smaller keys go left and larger keys go right. We’ll use distinct keys here.

1 / 3
Let’s picture it

Values alone do not preserve shape.

1 with left 2
1 with right 2

Trees root-left and root-right can both visit values 1,2 but have different topology.

Swipe when you’re ready
One little change

Record missing children.

1
null
2

Level order with null markers distinguishes where absent links occur. Trim only trailing nulls that add no shape information.

Same idea. One more small step.
Now it has a name

Restore parents in queue order.

parent
left token
right token

Read two child tokens for each queued real parent, creating nodes only for non-null values.

Want to try a tiny question?
No pressure. Just try it.

Why are null markers needed?

You can also keep scrolling
1 / 4
Trees

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Visit the same three dots.

A
B
C

We can say the parent’s name first, then visit its children.

1 / 3
You've reached the end of these ideas.Try them without the labels