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
This must be done in bash_profile | |
#if running bash | |
if [ -n "$BASH_VERSION" ]; then | |
# include .bashrc if it exits | |
if [ -f "$HOME/.bashrc" ]; then | |
. "$HOME/.bashrc" | |
fi | |
fi |
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
open zsh config : vim ~/.zshrc | |
At the bottom of the file add : source ~/.bash_profile |
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
prompt_context() { | |
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then | |
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER" | |
fi | |
} |
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
<link rel="icon" href="data:;base64,iVBORw0KGgo="> |
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
//ES5 version | |
function TreeNode(keyValue) { | |
this.keyValue = keyValue; | |
this.left = null; | |
this.right = null; | |
this.toString = function() { | |
return this.keyValue; | |
} | |
} |
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
//ES5 version | |
function TreeNode(keyValue) { | |
this.keyValue = keyValue; | |
this.left = null; | |
this.right = null; | |
this.toString = function() { | |
return this.keyValue; | |
} | |
} |
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
//ES5 VERSION | |
BinarySearchTree.prototype = { | |
insert: function(key) { | |
//create a new tree | |
var newNode = new TreeNode(key); | |
//if root is empty set the new node to be the root, else add recursively | |
this.root === null ? this.root = newNode : this.insertTo(this.root, newNode); | |
//increment counter | |
this.count++; | |
}, |
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 bst = new BinarySearchTree(); | |
bst.insert(60); | |
bst.insert(30); | |
bst.insert(85); | |
bst.insert(95); | |
bst.insert(80); | |
bst.insert(35); | |
bst.insert(20); | |
console.log(bst); |
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
BinarySearchTree.prototype = { | |
/* | |
other code here | |
*/ | |
inOrder: function(node){ | |
if (node !== null) { | |
//print the left subtree recursively | |
this.inOrder(node.left); | |
//print the root node | |
console.log(node.toString()); |
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
BinarySearchTree.prototype = { | |
/* | |
other code here | |
*/ | |
inOrder: function(node){ | |
if (node !== null) { | |
//print the left subtree recursively | |
this.inOrder(node.left); | |
//print the root node |