Skip to content
Snippets Groups Projects
Commit 7b52111c authored by Kevin Jahns's avatar Kevin Jahns
Browse files

fixed insertion bug in RBTree. adding does now work correctly

parent c184cb96
Branches
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@ class N {
this.right = newRight;
if (parent == null) {
tree.root = newParent;
newParent._parent = null;
} else if (parent.left === this) {
parent.left = newParent;
} else if (parent.right === this) {
......@@ -65,6 +66,7 @@ class N {
this.left = newLeft;
if (parent == null) {
tree.root = newParent;
newParent._parent = null;
} else if (parent.left === this) {
parent.left = newParent;
} else if (parent.right === this) {
......
/* @flow */
/*eslint-env browser,jasmine */
var numberOfTests = 1000;
var numberOfTests = 100000;
describe("RedBlack Tree", function(){
beforeEach(function(){
......@@ -24,7 +24,7 @@ describe("RedBlack Tree", function(){
var elements = [];
var tree = new RBTree();
for(var i = 0; i < numberOfTests; i++) {
var obj = (Math.random() + 1).toString(36).substring(15);
var obj = Math.floor(Math.random() * numberOfTests * 10000);
elements.push(obj);
tree.add({id: obj});
}
......
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment