|
| 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 | + [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], |
| 4 | + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 5 | + [0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0], |
| 6 | + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 7 | + [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0], |
| 8 | + [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], |
| 9 | + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 10 | + [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], |
| 11 | + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 12 | + [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0] |
| 13 | +]; |
| 14 | + |
| 15 | + |
| 16 | +var T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][1] indicates right child |
| 17 | + [-1,-1], |
| 18 | + [ 0, 2], |
| 19 | + [-1,-1], |
| 20 | + [ 1, 4], |
| 21 | + [-1,-1], |
| 22 | + [ 3, 8], |
| 23 | + [-1, 7], |
| 24 | + [-1,-1], |
| 25 | + [ 6,10], |
| 26 | + [-1,-1], |
| 27 | + [ 9,-1] |
| 28 | +]; |
| 29 | + |
| 30 | +var treeTracer = new DirectedGraphTracer( " Binary Tree Traversal Inorder ")._setTreeData ( G, 5 ); |
| 31 | +var arrayTracer = new Array1DTracer( " Binary Tree Print Inorder ")._setData ( new Array(T.length).fill( '-' ) ); |
| 32 | +var logger = new LogTracer ( " Log "); |
0 commit comments