Skip to content
Snippets Groups Projects
Commit 00aa7638 authored by Lawrence Chung's avatar Lawrence Chung
Browse files

ln 79 problem

parent 792c7301
No related branches found
No related tags found
No related merge requests found
......@@ -61,13 +61,13 @@ public class RedBlackTree<Key, Value> {
private static <T> Node put(Node h, Comparable<T> key, Comparable<T>[] val, GeneralCompare<T> gc){
int n = size(h);
Node root = new Node(key, val, n, true);
if(h == null)
return new Node(key, val, 1, true);
int n = size(h) + 1;
Node root = new Node(key, val, n, true);
int cmp = gc.compare(key, h.key());
if(cmp < 0)
h.left(put(h.left(), key, val, gc));
......@@ -76,7 +76,7 @@ public class RedBlackTree<Key, Value> {
else
h.val(val);
if(isRed(h.right()) && !isRed(h.left()))
if(isRed(h.right()) && !isRed(h.left())) // Problem here. makes reference to null on second iteration
h = rotateLeft(h);
if(isRed(h.left()) && isRed(h.left().left()))
h = rotateRight(h);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment