2012-02-07

SplayTreeQueue

Today I realised I hadn't yet tried a SplayTree, so that's what I spent this afternoon doing. I based the SplayTreeQueue on ftp://ftp.cs.cmu.edu/user/sleator/splaying/SplayTree.java. During development I got the "from running to running" error for the third time, this time it was fixed by replacing the contents of poll() from something like
E e = findMin();
remove(e);
return e;
to the contents of those functions. I still have no real idea what causes these errors...

I also optimised the removeMin operation a little (took advantage of the fact that findMin already splayed the tree on the the leftmost element, which means the remove() does not need to repeat this operation).

But unfortunately, no sigar. The SplayTreeQueue seems to be one of the slowest (definitely not faster than the JavaPriorityQueue) priority queues tested yet.

Geen opmerkingen:

Een reactie posten