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
Hello World! |
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
//Doubly Linked List is almost similar to singlyLinkedList, except every node has another pointer to the previous node. | |
class Node { | |
constructor(val, prev = null, next = null) { | |
this.val = val; | |
this.prev = prev; | |
this.next = next; | |
} | |
} |
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
//Stack implementation================================================================================== | |
// Stack is a container of objects that are inserted and removed according to the last-in first-out (LIFO) principle. | |
class Node { | |
constructor(data, next = null) { | |
this.data = data; | |
this.next = next; | |
} | |
} | |
class Stack { |
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
export default { | |
up() {}, | |
down(size) { | |
const sizes = { | |
xs: "575.98px", | |
sm: "767.98px", | |
md: "991.98px", | |
lg: "1199.98px", | |
xl: "1600px", | |
} |
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
// A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. | |
// Left child is always less than it's parent and the right child is always bigger than it's parent. | |
class Node { | |
constructor(value) { | |
this.value = value; | |
this.right = null; | |
this.left = null; | |
} | |
} |
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
//breadth_First_Search | |
//This method, visits tree's node horizontally and pushes them. It uses queue to keep track of its work. | |
//Example: 10 | |
// 6 15 | |
// 3 8 20 | |
//result node would be =[10, 6, 15, 3, 8, 20] | |
//The Breadth-first search algorithm that's shown in here, is for data structures like `Binary Search Tree`. |
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
//IMPORTANT | |
//aLL the tree traversal comments are written in here are based on BST or Binary Search Tree. | |
//IMPORTANT | |
//============================================================================================================ | |
//breadth_First_Search | |
//This method, visits tree's node horizontally and pushes them. It uses queue to keep track of its work. |
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
//BinaryHeaps are very similar to Binary Tree with some slightly different rules. It has two catagories, Max Binary Heap and Min Binary Heap | |
//In a Max Binary Heap, parent node is always larger than its child nodes and In a Min Binary Heap, parent node is always smaller than its child node. | |
//This snippet implementation of Max Binary Heap with JavaScript Arrays. | |
//Parent idx=n; leftChild idx=[2 * n + 1 ] and rightChild Idx=[2 * n + 2 ] | |
class MaxBinaryHeap { | |
constructor() { | |
this.values = []; | |
} |
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
class Node { | |
constructor(value, priority) { | |
this.value = value; | |
this.priority = priority; | |
} | |
} | |
class PriorityQueue { | |
constructor() { | |
this.values = []; |
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
//Hash tables are collection of key value pairs. | |
//This hash function uses Array to store data and uses separate chaining to avoid key collusion. | |
//Only works on alphabetic character string keys. | |
class Hash { | |
constructor(size = 5) { | |
this.table = new Array(size); | |
} | |
//hashes the given key/value. Using the given key, it finds an index on the Table and returns that index. | |
_hash(key) { |
OlderNewer