News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

B-Tree source code wanted

Started by z941998, September 16, 2009, 02:54:13 PM

Previous topic - Next topic

z941998

Hi folks,

I am starting a project on neural networks and need a good B-Tree to support my efforts.  I have done a lot of searching and found plenty in C++ but nothing in assembly format.

Does anyone have any suggestions.

Thanks
Steve

Slugsnack

if by B-Tree you mean binary tree, then i have a source implementing it.

you need a node structure that has 3 or more elements. 2 of those are for the left/right pointer. the other one is for the data

so you could use 2 DWORDs and then one whatever else. then you need to add code for stuff like add/delete. when you add a node you need to first dynamically allocate memory with sizeof the structure. the left/right pointers should be initialised to NULL. then the data one initialised as whatever data. then you find the position it would go in the tree ( easiest to do recursively ). once you have found a suitable parent node, change its respective pointer as the pointer to your newly allocated structure

z941998

Thank for responding,

What you have described is what I am looking for.  My intentions where to have dynamic control (ie recursive) and to attach to a database of 4.5 million records.  I would also like a feature where I could run tests, to determine the best structure (ie number of nodes versus number of keys [children] and then tree height).  Of course I will be linking in a system of file management because of the size of the databases.

Here's an example:  in horse racing there are T amount of tracks, with R amount of races per day, with D amount of days per year, and E amount of entries per race, with P amount of old pacelines.  After analysis, I want the top two horses to bet on.

With this much data I need a good B-Tree (or binary tree) and what you have indicated you have a model to start from.  This would help me a lot.

Thanks
Steve





Slugsnack

if it is the case that your BST is gonna be huge then it's probably worth it to put checks to see if it's balanced

do you still want a source example ?

z941998

I have 9 planned checks as to not violate a tree structure.  Yes I would like a example.