agl / critbit Goto Github PK
View Code? Open in Web Editor NEWCritbit trees in C
Critbit trees in C
Thank you for this. Your literate program has been a great help to play with a critbit tree in Ocaml. Section 25 is absent from the generated pdf. The missing section, titled "Check prefix," should be the last section and is referenced in section 23, which is titled "Fetching elements with a given prefix."
I'm curious about the proof you give, in section 12, for the statement "the only non-zero values for which the sets of true bits for x
and x โ 1
are disjoint, are powers of two". It seems incomplete to me.
You divide the number's bits up WLOG into three pieces: a (possibly empty) series of zeros, followed by a one, followed by a series ones and zeros. The number 1 (i.e. 0x01
) cannot be split as such.
1 is of course a power of two, and the most-significant 1 is maintained as a result of the described operations, so I think all you need to do is point out that the third series of bits may also be empty.
(P.S. Thanks for the awesome explanation, I was kind of lost with djb's relatively terse description.)
I wonder why he didnt write something like this:
function critbit_contains
......
if(q->byte<ulen){
}else{
return 0;
}
If the word you are looking is a prefix of many others, then the search will continue till the length of
the biggest word who has 0 bit in all the critical bits.
Lets assume that you want to start searching a word and then continue from there to the rest of the trie, ie searching for words that have the previous word as a prefix, you ll need to stop at the first internal node whose q->byte is less than your word, so as to use that internal node as the starting point for the new search.
Does that sound reasonable?
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.