Skip to content

Commit 6b9525d

Browse files
committed
add populating next right pointers in each node
1 parent 95732bf commit 6b9525d

File tree

1 file changed

+31
-2
lines changed
  • populating-next-right-pointers-in-each-node

1 file changed

+31
-2
lines changed
Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1+
## Recursion
12

2-
## TODO
3-
* write down thinking
3+
connecting left and right child is easy, just `node.left.next = node.right`
44

5+
6+
Before
7+
8+
```
9+
1
10+
/ \
11+
2 3
12+
/ \ / \
13+
4 5 6 7
14+
```
15+
16+
17+
After
18+
19+
```
20+
1
21+
/ \
22+
2 -> 3
23+
/ \ / \
24+
4-> 5 6->7
25+
```
26+
27+
`5` and `6` shoud be connected。
28+
29+
when connecting `4` and `5`, `2` and `3` is already connected, that is a good news, we can connect `5` and `6` using `2.next`.
30+
31+
```
32+
node.right.next = node.next.left;
33+
```

0 commit comments

Comments
 (0)