Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92e09c4

Browse files
committed
Revise LCA visualization
1 parent8ec07b2 commit92e09c4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

‎algorithm/tree/lowest_common_ancestor/binary_tree/code.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ function lcaBT (parent, root, a, b) {
2121
return(left!==null ?left :right);
2222
}
2323

24-
vara=7,b=9;
24+
vara=7,b=2;
2525
logger._print('Lowest common ancestor of '+a+' & '+b+' is: '+lcaBT(null,5,a,b));

‎algorithm/tree/lowest_common_ancestor/binary_tree/data.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
varG=[// G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
22
[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],
44
[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],
66
[0,0,0,0,0,0,0,0,0,0,0],
77
[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],
99
[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],
1111
[0,0,0,0,0,0,0,0,0,0,0],
1212
[0,0,0,0,0,0,0,0,0,1,0]
1313
];
1414

1515

1616
varT=[// mapping to G as a binary tree , [i][0] indicates left child, [i][1] indicates right child
1717
[-1,-1],
18-
[0,2],
18+
[-1,7],
1919
[-1,-1],
20-
[1,4],
20+
[6,1],
2121
[-1,-1],
2222
[3,8],
23-
[-1,7],
23+
[0,2],
2424
[-1,-1],
25-
[6,10],
25+
[10,4],
2626
[-1,-1],
2727
[9,-1]
2828
];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp