Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Range Sum of BST
Bookmark
DFS All Nodes
DFS Pruned
BFS Pruned
Input
Standard
All in range
Narrow range
Custom
tree
=
[10, 5, 15, 3, 7, null, 18]
,
low
=
7
,
high
=
15
Range: [7, 15]
10
5
15
3
7
18
Sum = 0
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
Sum = 0
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
node
Call Stack
rangeSumBST(5)
rangeSumBST(10)
Sum = 10
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
node
Call Stack
rangeSumBST(3)
rangeSumBST(5)
rangeSumBST(10)
Sum = 10
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
node
Call Stack
rangeSumBST(3)
rangeSumBST(5)
rangeSumBST(10)
Sum = 10
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
node
Call Stack
rangeSumBST(7)
rangeSumBST(5)
rangeSumBST(10)
Sum = 17
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
node
Call Stack
rangeSumBST(7)
rangeSumBST(5)
rangeSumBST(10)
Sum = 17
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
node
Call Stack
rangeSumBST(15)
rangeSumBST(10)
Sum = 32
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
node
Call Stack
rangeSumBST(18)
rangeSumBST(15)
rangeSumBST(10)
Sum = 32
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
Call Stack
rangeSumBST(null)
rangeSumBST(18)
rangeSumBST(15)
rangeSumBST(10)
Sum = 32
In range
Current
Skipped
Pruned
Range: [7, 15]
10
5
15
3
7
18
Call Stack
empty
Sum = 32
In range
Current
Skipped
Pruned
algo
master
.
io
Step:
Start: visit every node and sum the ones inside [7, 15]
0 / 38
Input
Standard
All in range
Narrow range
Custom
tree
=
[10, 5, 15, 3, 7, null, 18]
,
low
=
7
,
high
=
15
0 / 38
algo
master
.
io
Step:
Start: visit every node and sum the ones inside [7, 15]