|
1 |
| -var G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not |
2 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
3 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
4 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
5 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
6 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
7 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
8 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
9 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
10 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
11 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
12 |
| - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
13 |
| -]; |
| 1 | +var G = []; |
14 | 2 |
|
15 | 3 |
|
16 |
| -var T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][1] indicates right child |
17 |
| - [-1,-1], |
18 |
| - [-1,-1], |
19 |
| - [-1,-1], |
20 |
| - [-1,-1], |
21 |
| - [-1,-1], |
22 |
| - [-1,-1], |
23 |
| - [-1,-1], |
24 |
| - [-1,-1], |
25 |
| - [-1,-1], |
26 |
| - [-1,-1], |
27 |
| - [-1,-1] |
28 |
| -]; |
| 4 | +var T = {}; |
29 | 5 |
|
30 | 6 | var elements = [5,8,10,3,1,6,9,7,2,0,4]; // item to be searched
|
31 | 7 | var tracer = new DirectedGraphTracer( " BST - Elements marked red indicates the current status of tree ");
|
|
0 commit comments