GeezerVison is showing github.com — Merge pull request #210 from archie94/lca-revise · AquaMir/AlgorithmVisualizer@52dbc4c
File treeExpand file treeCollapse file tree Open diff view settings algorithm/tree/lowest_common_ancestor/binary_tree
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: algorithm/tree/lowest_common_ancestor/binary_tree/code.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,5 +21,5 @@ function lcaBT (parent, root, a, b) { | 21 | 21 | return (left !== null ? left : right); | 22 | 22 | } | 23 | 23 |
| 24 | | -var a = 7, b = 9; | | 24 | +var a = 7, b = 2; | 25 | 25 | logger._print ('Lowest common ancestor of ' + a + ' & ' + b + ' is: ' + lcaBT (null, 5, a, b)); |
Collapse file Copy file name to clipboardExpand all lines: algorithm/tree/lowest_common_ancestor/binary_tree/data.js +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | var G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not | 2 | 2 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 3 | | - [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | | 3 | + [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], | 4 | 4 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 5 | | - [0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0], | | 5 | + [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0], | 6 | 6 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 7 | 7 | [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0], | 8 | | - [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], | | 8 | + [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | 9 | 9 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 10 | | - [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], | | 10 | + [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], | 11 | 11 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 12 | 12 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0] | 13 | 13 | ]; | 14 | 14 |
| 15 | 15 |
| 16 | 16 | var T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][1] indicates right child | 17 | 17 | [-1,-1], | 18 | | - [ 0, 2], | | 18 | + [-1, 7], | 19 | 19 | [-1,-1], | 20 | | - [ 1, 4], | | 20 | + [ 6, 1], | 21 | 21 | [-1,-1], | 22 | 22 | [ 3, 8], | 23 | | - [-1, 7], | | 23 | + [ 0, 2], | 24 | 24 | [-1,-1], | 25 | | - [ 6,10], | | 25 | + [10, 4], | 26 | 26 | [-1,-1], | 27 | 27 | [ 9,-1] | 28 | 28 | ]; | |
|