-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
32 lines (26 loc) · 1.08 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
// Test Runner
////////////// Traversals ///////////////////
console.log("Traversals");
var traversals = require('./algos/traversals');
var binaryTree = require('./sample/binaryTree');
Object.keys(traversals).forEach(function(traversal){
console.log(traversal);
traversals[traversal](binaryTree, console.log);
});
////////////////////////////////////////////
/////////////// isBST ////////////////////////
var isBST = require('./problems/isBst');
var binarySearchTree = require('./sample/binarySearchTree');
console.log("Binary Tree is BST");
console.log("Is BST? " + isBST(binarySearchTree));
console.log("Is BST? " + isBST(binaryTree));
//////////////////////////////////////////////
/////////////// minCostPath ////////////////////////
var printMatrix = require('./lib/util').printMatrix;
var minCostPath = require('./problems/minCostPath');
var sampleCostMatix = require('./sample/costMatix');
console.log("Cost matrix");
printMatrix(sampleCostMatix, 3);
console.log("Minimum Cost: ", minCostPath(sampleCostMatix, 3, 3));
/////////////////////////////////////////////////////