fbuihuu / libtree Goto Github PK
View Code? Open in Web Editor NEWA library which implements a couple of famous binary search trees.
License: GNU Lesser General Public License v2.1
A library which implements a couple of famous binary search trees.
License: GNU Lesser General Public License v2.1
Hello,
I tried to run basic robustness test on libtree inserting 1k random keys comparing the order in a list of these numbers and the tree.
Unfortunately, the compare fails.
Maybe there is some off-by-one error somewhere and I am comparing uninitialized value or there is some issue with my understanding of the walk function in libtree.
Anyway, here is the code I tried git://gist.github.com/2045182.git
Note that I get assert on 5th element for which I have visually inspected my list implementation to produce seemingly correct order with this number sequence.
<- 1536452766
1536452766 <- 2219981191
1536452766 2219981191 <- 2013842191
1536452766 2013842191 2219981191 <- 206515713
206515713 1536452766 2013842191 2219981191 <- 3973769363
206515713 1536452766 2013842191 2219981191 3973769363
bs tree: item 0 (3973769363) != 206515713
inserted items:
1536452766 2219981191 2013842191 206515713 3973769363
Aborted
<- 1536452766
1536452766 <- 2219981191
1536452766 2219981191 <- 2013842191
1536452766 2013842191 2219981191 <- 206515713
206515713 1536452766 2013842191 2219981191 <- 3973769363
206515713 1536452766 2013842191 2219981191 3973769363
splay tree: item 0 (3973769363) != 206515713
inserted items:
1536452766 2219981191 2013842191 206515713 3973769363
The sequence for avl and rb tree is longer but again the last inserted item appears first:
1536452766 2219981191 2013842191 206515713 3973769363 2195571548 1470591614 99517740 3346335896 1968000334 2824163306 825862710 593949289 3087228942 9464287 3502443898 1825977738 4200665288
<- 1536452766
1536452766 <- 2219981191
1536452766 2219981191 <- 2013842191
1536452766 2013842191 2219981191 <- 206515713
206515713 1536452766 2013842191 2219981191 <- 3973769363
206515713 1536452766 2013842191 2219981191 3973769363 <- 2195571548
206515713 1536452766 2013842191 2195571548 2219981191 3973769363 <- 1470591614
206515713 1470591614 1536452766 2013842191 2195571548 2219981191 3973769363 <- 99517740
99517740 206515713 1470591614 1536452766 2013842191 2195571548 2219981191 3973769363 <- 3346335896
99517740 206515713 1470591614 1536452766 2013842191 2195571548 2219981191 3346335896 3973769363 <- 1968000334
99517740 206515713 1470591614 1536452766 1968000334 2013842191 2195571548 2219981191 3346335896 3973769363 <- 2824163306
99517740 206515713 1470591614 1536452766 1968000334 2013842191 2195571548 2219981191 2824163306 3346335896 3973769363 <- 825862710
99517740 206515713 825862710 1470591614 1536452766 1968000334 2013842191 2195571548 2219981191 2824163306 3346335896 3973769363 <- 593949289
99517740 206515713 593949289 825862710 1470591614 1536452766 1968000334 2013842191 2195571548 2219981191 2824163306 3346335896 3973769363 <- 3087228942
99517740 206515713 593949289 825862710 1470591614 1536452766 1968000334 2013842191 2195571548 2219981191 2824163306 3087228942 3346335896 3973769363 <- 9464287
9464287 99517740 206515713 593949289 825862710 1470591614 1536452766 1968000334 2013842191 2195571548 2219981191 2824163306 3087228942 3346335896 3973769363 <- 3502443898
9464287 99517740 206515713 593949289 825862710 1470591614 1536452766 1968000334 2013842191 2195571548 2219981191 2824163306 3087228942 3346335896 3502443898 3973769363 <- 1825977738
9464287 99517740 206515713 593949289 825862710 1470591614 1536452766 1825977738 1968000334 2013842191 2195571548 2219981191 2824163306 3087228942 3346335896 3502443898 3973769363 <- 4200665288
9464287 99517740 206515713 593949289 825862710 1470591614 1536452766 1825977738 1968000334 2013842191 2195571548 2219981191 2824163306 3087228942 3346335896 3502443898 3973769363 4200665288
avl tree: item 0 (4200665288) != 9464287
inserted items:
1536452766 2219981191 2013842191 206515713 3973769363 2195571548 1470591614 99517740 3346335896 1968000334 2824163306 825862710 593949289 3087228942 9464287 3502443898 1825977738 4200665288
Aborted
The API description in README does not specify the return value of lookup function when the passed key value is not present in the tree.
It should maintain "thread" pointers by updating them to point to the new node as well.
For instance:
set_next(new, get_prev(old)); // NOTE: it just telling the point, not necessary to be correct
In my test program, an infinite lookup loop comes up easily with random datasets and with using bstree_replace()
. But everything was fine without bstree_replace()
.
Only the shared library is installed, not the symlinks that allow linking to it.
While it might be possible to create these symlinks with some system tool the makefile does not do it making the library unlinkable and unpackagable.
hmm, install can't install symlinks so here is a different patch https://github.com/hramrach/libtree/commit/2d948f85e2313c043820f5c946b251c6e2358909
COPYING says LGPL 2.1, source files say Library general public license 2 (a license that does not exist, see http://www.gnu.org/licenses/old-licenses/old-licenses.html#LGPL). This is a problem
Do you mean to license under LGPL 2.1+, if so, change the headers of your source files to the fallowing:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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.