fixed insertion bug in RBTree. adding does now work correctly

This commit is contained in:
Kevin Jahns 2015-07-07 21:17:28 +02:00
parent c184cb961b
commit 7b52111c31
4 changed files with 6 additions and 4 deletions

View File

@ -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) {

View File

@ -1,7 +1,7 @@
/* @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});
}

2
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long