21 lines
1.5 KiB
Plaintext
21 lines
1.5 KiB
Plaintext
Morris inorder on the sample tree, step by step
|
|
===============================================
|
|
|
|
step | action | threads (from node) | output so far
|
|
1 | at 1: thread 5 -> 1, go left | [5] | []
|
|
2 | at 2: thread 4 -> 2, go left | [5 4] | []
|
|
3 | at 4: no left child, visit, go right | [5 4] | [4]
|
|
4 | at 2: thread from 4 found, remove it, visit, go right | [5] | [4 2]
|
|
5 | at 5: thread 7 -> 5, go left | [5 7] | [4 2]
|
|
6 | at 7: no left child, visit, go right | [5 7] | [4 2 7]
|
|
7 | at 5: thread from 7 found, remove it, visit, go right | [5] | [4 2 7 5]
|
|
8 | at 1: thread from 5 found, remove it, visit, go right | [] | [4 2 7 5 1]
|
|
9 | at 3: no left child, visit, go right | [] | [4 2 7 5 1 3]
|
|
10 | at 6: thread 8 -> 6, go left | [8] | [4 2 7 5 1 3]
|
|
11 | at 8: no left child, visit, go right | [8] | [4 2 7 5 1 3 8]
|
|
12 | at 6: thread from 8 found, remove it, visit, go right | [] | [4 2 7 5 1 3 8 6]
|
|
13 | at 9: no left child, visit, go right | [] | [4 2 7 5 1 3 8 6 9]
|
|
|
|
tree before: 1(2(4,5(7,-)),3(-,6(8,9)))
|
|
tree after : 1(2(4,5(7,-)),3(-,6(8,9)))
|