This file contains 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
var BinarySearchTree = function(value){ | |
var instance = Object.create(binaryTreeMethods); | |
instance.value = value | |
instance.left = null; | |
instance.right = null; | |
return instance; |
This file contains 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
var reverseList = function(list){ | |
var tempHead = list.head; | |
var tempTail = list.tail; | |
var prevNode = list.head | |
var currentNode = this.head.next; | |
while(currentNode) { | |
var holder = currentNode.next; | |
currentNode.next = prevNode; | |
prevNode = currentNode; | |
currentNode = holder |
This file contains 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 isBalanced (string) { | |
var queue = []; | |
for(var i = 0; i < string.length; i++){ | |
if(string[i] === "("){ | |
queue.push(string[i]); | |
} | |
if(string[i] === ")"){ | |
queue.pop(); | |
} | |
} |
This file contains 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 makeBoard(n) { | |
var board = [] | |
for (var i = 0; i < n; i++) { | |
board.push([]) | |
for (var j = 0; j < n; j++) { | |
board[i].push(false) | |
} | |
} | |
board.togglePiece = function(i, j) { | |
this[i][j] = !this[i][j] |
This file contains 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
/* | |
Example usage: | |
var obj = mixEvents({ name: 'Alice', age: 30 }); | |
obj.on('ageChange', function(){ // On takes an event name and a callback function | |
console.log('Age changed'); | |
}); | |
obj.age++; | |
obj.trigger('ageChange'); // This should call our callback! Should log 'age changed'. | |
*/ |
This file contains 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
var matrix = | |
[ [ 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 ] ]; | |
var spiralTraversal = function(matrix){ | |
var results =[]; | |
var startRowIndex = 0; |
This file contains 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
set -o verbose | |
set -o errexit | |
echo '* Create and initialize a repository.' | |
git init gitflow-tutorial | |
cd gitflow-tutorial/ | |
git flow init -d | |
echo '* Develop a Feature' |
This file contains 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
var app = angular.module("modalFormApp", ['ui.bootstrap']); | |
app.controller("modalAccountFormController", ['$scope', '$modal', '$log', | |
function ($scope, $modal, $log) { | |
$scope.showForm = function () { | |
$scope.message = "Show Form Button Clicked"; | |
console.log($scope.message); | |
var modalInstance = $modal.open({ |
This file contains 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
var compose = function(){ | |
//Your code here | |
var args = Array.prototype.slice.call(arguments); | |
return function(val){ | |
return args.reduceRight(function(memo, fn){ | |
return fn(memo); | |
}, val); | |
}; | |
}; |
This file contains 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
var bubbleSort = function(array) { | |
var len = array.length; | |
var swap = function(i,j,array){ | |
var holder = array[i]; | |
array[i] = array[j]; | |
array[j] = holder; | |
} | |
for(var j = 0; j < len - 1; j++){ | |
var swaps = false; |