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
| const swap = (arr, idx1, idx2) => { | |
| [ arr[idx1], arr[idx2] ] = [ arr[idx2], arr[idx1] ]; | |
| }; | |
| /*********** Bubble Sort O(n^2) ***********/ | |
| const bubbleSort = (arr) => { | |
| let noSwaps; | |
| for (let i = arr.length; i > 0; i--) { | |
| noSwaps = true; |
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
| class Node { | |
| constructor (val) { | |
| this.val = val; | |
| this.next = null; | |
| } | |
| } | |
| class SinglyLinkedList { | |
| constructor () { | |
| this.head = 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
| class Node { | |
| constructor (val) { | |
| this.val = val; | |
| this.prev = null; | |
| this.next = null; | |
| } | |
| } | |
| class DoublyLinkedList { | |
| constructor () { |
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
| class Node { | |
| constructor (value) { | |
| this.value = value; | |
| this.left = null; | |
| this.right = null; | |
| } | |
| } | |
| class BinarySearchTree { | |
| constructor () { |
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
| class MaxBinaryHeap { | |
| constructor () { | |
| this.values = []; | |
| } | |
| insert (value) { | |
| this.values.push(value); | |
| this.bubbleUp(); | |
| } |
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
| class Node { | |
| constructor (value, priority) { | |
| this.value = value; | |
| this.priority = priority; | |
| } | |
| } | |
| class PriorityQueue { | |
| constructor () { | |
| this.values = []; |
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
| class Graph { | |
| constructor () { | |
| this.adjacencyList = {}; | |
| } | |
| addVertex (vertex) { | |
| if (!this.adjacencyList[vertex]) this.adjacencyList[vertex] = []; | |
| } | |
| addEdge (vertex1, vertex2) { |
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
| class Node { | |
| constructor (value, priority) { | |
| this.value = value; | |
| this.priority = priority; | |
| } | |
| } | |
| class PriorityQueue { | |
| constructor () { | |
| this.values = []; |
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
| enum ListLevel { | |
| AUTHORS = 'AUTHORS', | |
| ARTICLES = 'ARTICLES' | |
| } | |
| interface Pagination { | |
| first: number; | |
| last: number; | |
| } |
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
| this.listTitle$ = this.listLevel$.pipe( | |
| map(listLevel => { | |
| switch (listLevel) { | |
| case ListLevel.AUTHORS: | |
| return 'Trending authors that published few minutes ago!'; | |
| case ListLevel.ARTICLES: | |
| return 'Best articles for you!'; | |
| default: | |
| break; | |
| } |
OlderNewer