English 中文(简体)
How are B Tree nodes typically represented?
原标题:

I ve been doing some brushing up on my B-Tree and 2-3-4 tree (B tree with order 4), and I m attempting to implement this in C#. My question to you is, given that a B-Tree node can contains N-1 number of items and N subtrees, what is the typical representation for one of these nodes? Is it an array, series of linked-lists, or something I ve not considered?

最佳回答

For a 2-3-4 tree, it does not really matter. For large orders, you d use a sorted array and binary search. For variable-size keys like Strings, a trie might be a good idea.

问题回答

Don t try to combine sub-trees and items. You will need 2 arrays or List<> s.

If your order is fixed i would use 2 arrays. Otherwise, a List<ItemClass> and a List<SubTree>

Here s an interesting article on MSDN about writing a binary search tree in C#. Not exactly the same as a b-tree but you may find it useful. The author in this case uses a generic Collection base class:

public class Node<T>
{
   private T data;
   private NodeList<T> neighbors = null;
   ...
}

public class NodeList<T> : Collection<Node<T>> { ... }




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签