(self, root)
| 53 | # @param root, a tree link node |
| 54 | # @return nothing |
| 55 | def connect(self, root): |
| 56 | if not root: |
| 57 | return |
| 58 | |
| 59 | current = [root] |
| 60 | next_nodes = [] |
| 61 | |
| 62 | while current or next_nodes: |
| 63 | for i in current: |
| 64 | if i.left: |
| 65 | if next_nodes: |
| 66 | next_nodes[-1].next = i.left |
| 67 | |
| 68 | next_nodes.append(i.left) |
| 69 | if i.right: |
| 70 | if next_nodes: |
| 71 | next_nodes[-1].next = i.right |
| 72 | |
| 73 | next_nodes.append(i.right) |
| 74 | |
| 75 | current = next_nodes |
| 76 | next_nodes = [] |
| 77 |
nothing calls this directly
no outgoing calls
no test coverage detected