kuychaco / algoclass Goto Github PK
View Code? Open in Web Editor NEWCommon data structures and algorithms
Common data structures and algorithms
Hi, I've made my way here from front end masters. Your course has been great!
I've come to the BST section of your course and in the videos you go over the solutions to deleting a node from a binary search tree. Issues are:
You only write pseudo code for the cases that have 0 or 1 child nodes. No solution is shown in the videos or within your solution branches.
For the 3rd case in which there are 2 children nodes, you show the code for when we are trying to delete the root and when the value we are deleting is not the root. Issue is, you add in a root property to the code, when throughout the rest of the BST constructor we have not used a root. How would this affect the rest of the code? Would we just replace our parent checks with referencing the root?
Essentially I'm asking for the BST solution to be updated to a full solution. Thank you.
the this
keyword within the callback function is bounded to the Window
object, so it throws an error.
The fix is either to use an arrow function or store the this
keyword in a variable & use it instead.
In the definition of the LinkedList.forEach function:
LinkedList.prototype.forEach = function(callback) { var node = this.head; while (node) { callback(node.value); node = node.next; } };
Doesn't the node = node.next;
line incorrectly refer only to a reference (node.next), rather than an actual node object?
Thanks.
Hi,
Thanks you for these execises!
I have a question about graph depth first traversal - I don't understand why the distance for 4 is 2 in the below example taken from graph.js. I would expect it to be 4, 1
since it is only 1 away from 1.
Example Usage:
1---2---3---5
\ /
4
{
'1': [ 2, 4 ],
'2': [ 1, 3, 4 ],
'3': [ 2, 5 ],
'4': [ 1, 2 ],
'5': [ 3 ]
}
var traverseDF = [];
graph.traverseDepthFirst(1, function(val, distance) { traverseDF.push([val, distance]) });
traverseDF should be [ [ 1, 0 ], [ 2, 1 ], [ 3, 2 ], [ 5, 3 ], [ 4, 2 ]
]
Tree.js traverseDepthFirst doesn't return the correct order.
Tree.prototype.traverseDepthFirst= function(fn){
this.children.forEach(function(child){
child.traverseDepthFirst(fn);
});
fn(this)
}
Based on the example dataset:
var tree = new Tree(1);
var branch1 = tree.addChild(2);
var branch2 = tree.addChild(3);
var branch3 = tree.addChild(4);
branch1.addChild(5);
branch1.addChild(6);
branch3.addChild(7).addChild(8);
The correct order should be: [1, 2, 5, 6, 3, 4, 7, 8]
Instead it returns: [5, 6, 2, 3, 8, 7, 4, 1]
algoClass/data-structures/doublyLinkedList.js
Line 157 in 58517aa
algoClass/data-structures/queue.js
Line 153 in 58517aa
Queue_TwoStack should receive capacity argument and pass to new Stack, like below.
function Queue_TwoStack (capacity) {
this._stackIn = new Stack(capacity);
this._stackOut = new Stack(capacity);
}
algoClass/data-structures/queue.js
Line 159 in 58517aa
algoClass/data-structures/stack.js
Line 81 in 813224e
I can't seem to figure out what the question is asking. When implementing the stack I had it look like so
{1: 'ABC', 2: 'DEF'...}
. But won't get the minimum value be 0 ? Or should we use numbers as values ? I am bit confused
In line 123: Infinity is spelled 'Infninty'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.