This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function partition(arr, left, right, pivot) { | |
| var temp = arr[pivot]; | |
| arr[pivot] = arr[right]; | |
| arr[right] = temp; | |
| var track = left; | |
| for (var i = left; i < right; i++) { | |
| if (arr[i]<arr[right]) { | |
| var t = arr[i]; | |
| arr[i] = arr[track]; | |
| arr[track] = t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function AVLTreeNode(val,left,right) { | |
| this.val = val; | |
| this.left = left || null; | |
| this.right = right || null; | |
| this.height = 0; | |
| } | |
| function AVLTree(comparator) { | |
| this.comparator = comparator; | |
| this.root = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| ;(function(global) { | |
| function SegmentTreeNode(left, right, reocrd) { | |
| this.left = left; | |
| this.right = right; | |
| this.leftChild = null; | |
| this.rightChild = null; | |
| this.cover = false; | |
| this.record = reocrd; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fillArray(arr, size, val) { | |
| for (var i = 0; i < size; i++) { | |
| arr[i] = val; | |
| } | |
| } | |
| function binarySearch (array, target, start, end) { | |
| var l = start || 0; | |
| var r = end || array.length - 1; | |
| while (l<=r) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function binarySearch (array, target, start, end) { | |
| var l = start || 0; | |
| var r = end || array.length - 1; | |
| while (l<=r) { | |
| var mid = Math.floor((l+r)/2); | |
| if (array[mid]==target) { | |
| return mid; | |
| } else if (array[mid]>target) { | |
| r = mid - 1; | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function SuffixTrieNode() { | |
| this.children = {}; | |
| this.link = null; | |
| } | |
| SuffixTrieNode.prototype.addLink = function(c, v) { | |
| this.children[c] = v; | |
| }; | |
| function SuffixTrie(s) { |