Questions tagged [b-tree]

B-trees are a type of self balancing search tree where each node can hold multiple keys and all leaf nodes are the same distance from the root.

B-trees are an extension of self-balancing binary search trees to allow each node to hold multiple keys and have multiple children. They are designed to take advantage of systems that can read and write in large blocks, and are commonly used in databases and file systems.

B-trees on Wikipedia

762 questions
22
votes
6 answers

Is there a B-Tree Database or framework in Python?

I heard that B-Tree databases are faster than Hash tables, so I thought of using a B-Tree database for my project. Is there any existing framework in python which allows us to use such Data structure or will I have to code from scratch?
Rahul
  • 11,129
  • 17
  • 63
  • 76
22
votes
3 answers

Why do we need a separate datastructure like B-Tree for database and file system?

I am reading up on B Trees and looks like they achieve the dynamic set operations in O(lg n) time . The Red Black Tree( TreeMap in java ) also achieves the same operation in asymptotically the same time frame . So I would like to know what makes B…
Geek
  • 26,489
  • 43
  • 149
  • 227
20
votes
1 answer

How to find next smaller key in BTreeMap/BTreeSet?

If I understand b-trees correctly, it should be easy and possible in logarithmic time to search for a key. If the key is not existent, it can return the next smaller and larger key; the neighbors of the given key if it would get inserted. Does this…
blacktemplar
  • 699
  • 1
  • 7
  • 21
18
votes
4 answers

B-Trees / B+Trees and duplicate keys

I'm investigating the possibility of putting together a custom storage scheme for my application. It's worth the effort of potentially reinventing the wheel, I think, because both performance and storage efficiency are a main objective and the data…
Kieren Johnstone
  • 41,277
  • 16
  • 94
  • 144
18
votes
2 answers

How btree is stored on disc?

I know how to implement btree in memory, but not clear about how to store btree in disc. I think there are two major difference: Conversion between memory pointer and disc address, see this post. How to split page when insert new k/v item? It is…
Chang
  • 3,953
  • 2
  • 30
  • 43
18
votes
2 answers

What is a B-tree page

I think I know what a B-tree is but what is a B-tree page?
neuromancer
  • 53,769
  • 78
  • 166
  • 223
18
votes
3 answers

Why are skip lists not preferred over B+-trees for databases?

I was reading about skip lists and MemSQL and was wondering why skip lists are not more widely used in databases? Are there any major disadvatages to using skiplists?
lucidxistence
  • 409
  • 5
  • 15
18
votes
1 answer

What is satellite information in data structures?

Taken from Introduction to Algorithms by Thomas Cormen: To keep things simple, we assume, as we have for binary search trees and red-black trees, that any “satellite information” associated with a key is stored in the same node as the key. In…
jantristanmilan
  • 4,188
  • 14
  • 53
  • 69
17
votes
4 answers

What's the difference between B-Tree and GiST index methods (in PostgreSQL)?

I have been working on optimizing my Postgres databases recently, and traditionally, I've only ever use B-Tree indexes. However, I saw that GiST indexes suport non-unique, multicolumn indexes, in the Postgres 8.3 documentation. I couldn't, however,…
Ash
  • 24,276
  • 34
  • 107
  • 152
17
votes
5 answers

javascript binary search tree implementation

Anyone know of any good examples of a simple BTree implementation in Javascript? I have a bunch of "things" arriving randomly, and want to insert each one efficiently. Ultimately, each new one will get inserted into the DOM based on where it ends…
brad
  • 423
  • 2
  • 5
  • 11
16
votes
3 answers

How can I avoid wasteful copying of keys in a B-tree based STL-like map?

I'm replacing a use of std::map in a hot path with cpp-btree's btree_map. But with optimization enabled, GCC and Clang complain about a strict aliasing violation. The problem boils down to this: template class…
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
16
votes
5 answers

How to, given a predetermined set of keys, reorder the keys such that the minimum number of nodes are used when inserting into a B-Tree?

So I have a problem which i'm pretty sure is solvable, but after many, many hours of thinking and discussion, only partial progress has been made. The issue is as follows. I'm building a BTree of, potentially, a few million keys. When searching the…
Squimmy
  • 445
  • 1
  • 3
  • 11
15
votes
3 answers

How can I get the last item in a BTreeMap?

If you have a sorted map of key/value pairs (or just keys), one of the obvious operations is to get the first or last pair (or key). C++'s std::vector has front() and back() for this purpose. std::map doesn't, but *map.begin() and *map.rbegin()…
dhardy
  • 11,175
  • 7
  • 38
  • 46
15
votes
2 answers

how B-tree indexing works in mysql

When I create an index for a table in mysql, I see that the index_type is type BTREE. Now although I understand about btree(s), I do not quiet understand how it stores the index and how the database searches the records based on this. I mean, btree…
JPro
  • 6,292
  • 13
  • 57
  • 83
14
votes
4 answers

Are there any tools to estimate index size in MongoDB?

I'm looking for a tool to get a decent estimate of how large a MongoDB index will be based on a few signals like: How many documents in my collection The size of the indexed field(s) The size of the _id I'm using if not ObjectId Geo/Non-geo Has…
jpredham
  • 2,149
  • 1
  • 23
  • 37
1
2
3
50 51