Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Recover Binary Search Tree
Bookmark
Inorder + Sort
Inversion Detection
Morris O(1)
Input
Adjacent swap (3<->2)
Non-adjacent swap (3<->2)
Root swap (3<->1)
Custom
tree
=
[1, 3, null, null, 2]
1
3
2
Inorder
empty
Current
Visited
Misplaced
Fixed
1
3
2
Inorder
empty
Current
Visited
Misplaced
Fixed
1
3
2
current
Inorder
empty
Current
Visited
Misplaced
Fixed
1
3
2
current
Inorder
3
Current
Visited
Misplaced
Fixed
1
3
2
current
Inorder
3
2
Current
Visited
Misplaced
Fixed
1
3
2
current
Inorder
3
2
1
Current
Visited
Misplaced
Fixed
1
3
2
current
Inorder
3
2
1
Sorted
1
2
3
Current
Visited
Misplaced
Fixed
1
1
2
current
Inorder
3
2
1
Sorted
1
2
3
Current
Visited
Misplaced
Fixed
1
1
2
current
Inorder
3
2
1
Sorted
1
2
3
Current
Visited
Misplaced
Fixed
3
1
2
current
Inorder
3
2
1
Sorted
1
2
3
Current
Visited
Misplaced
Fixed
3
1
2
Inorder
1
2
3
Sorted
1
2
3
Current
Visited
Misplaced
Fixed
algo
master
.
io
Step:
values = [] (collect the in-order sequence first)
0 / 30
Input
Adjacent swap (3<->2)
Non-adjacent swap (3<->2)
Root swap (3<->1)
Custom
tree
=
[1, 3, null, null, 2]
0 / 30
algo
master
.
io
Step:
values = [] (collect the in-order sequence first)