B-Tree | B-Tree Implementation in C. A project in Data Structures | Dataset library
kandi X-RAY | B-Tree Summary
kandi X-RAY | B-Tree Summary
B-Tree Implementation in C. A project in Data Structures.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of B-Tree
B-Tree Key Features
B-Tree Examples and Code Snippets
Community Discussions
Trending Discussions on B-Tree
QUESTION
Given a new implementation of tree in Scheme using list:
...ANSWER
Answered 2021-Jun-09 at 23:06You have a reasonable-looking sequence of if
tests (though using cond
instead would be more idiomatic Scheme). But the values you return do not generally look correct.
The first problem I see is in your first if
clause. If both trees are empty, you return '()
. But according to the spec, you should be calling the succ
function with that result. This may look unimportant if you use id
as your continuation, but note that each recursive step builds up a more detailed succ
continuation, so in general succ
may be a quite impactful function.
The second if
is also a problem. Again you return '()
, when you are supposed to return the first conflicting subtrees. It's not clear to me what that means, but it would be reasonable to pass a pair of tree1
and tree2
to fail
.
The third and fourth clause look fine. You call succ
with a pair of the two leaves, as expected.
The recursive call is clearly wrong: you have mis-parenthesized calls to cons
, and your lambda variable is named X
but you refer to it as x
. The series of cons
calls doesn't really look right either, but you can experiment with that once your more pressing syntactic issues are resolved and your base cases work properly.
Lastly, you are doing a lot of low-level work with cons
, car
, '()
, and so on. You should be using the abstract functions provided to you, such as add-subtree
and (make-tree)
, instead of using the low-level primitives they are built on.
QUESTION
I'm writing a B-tree in c and it's getting pretty big. I have a struct for the tree, one for the nodes, and one for the items (key/value). I'd like to compile the object files from all three header files into an archive (.a) using make. Whenever I try to compile using make it uses the archive without every building the objects. Any idea why?
...ANSWER
Answered 2021-Jun-05 at 21:12Most likely because your sources variable src
is empty. Which means your objects list variable obj
is empty. Which means that your library lib/btree.a
doesn't depend on anything, so make doesn't build anything.
This is most likely because this:
QUESTION
I'm trying to sort key/val structs in an array that it's a tree node of a b-tree. When I insert a key/val struct into a node I place it at the end of the struct then perform a qsort.
...ANSWER
Answered 2021-Jun-03 at 17:25The compare function is passed addresses to elements. You sort array of pointers. So compare function receives a pointer to the pointer in the array. Do:
QUESTION
I have a Postgre table “tasks” with the fields “start”:timestamptz, “finish”:timestamptz, “type”:int (and a lot of others). It contains about 200m records. Start, finish and type fields have a separate b-tree indexes. I’d like to build a report “Tasks for a period” and need to get all tasks which lay (fully or partially) inside the reporting period. Report could be built for all task types or for the specific one. So I wrote the SQL:
...ANSWER
Answered 2021-May-30 at 13:54You would want a GiST index on the range. Since you already have it stored as two end points rather than as a range, you could do a functional index to convert them on the fly.
QUESTION
How RDBs like MySQL and PostgreSQL manage memory for new indexes?
My guess that RDB creates B-tree (or other indexes) with References/Links to real objects in memory. Another guess that it duplicates all the data for each new index.
So basically this question is about "What B-tree consists of? References, or real objects?"
Google search is too overheat about DB topics and RDMS products. So, I also would be very grateful for good articles about this.
...ANSWER
Answered 2021-May-19 at 17:07The details vary, but a B-tree index is a tree structure that is stored on disk. It contains duplicates of the indexed terms (the index keys) and a (direct or indirect) pointer to the indexed row in the table.
A B-tree index represents a sorted list of the index keys that allows fast searches. The tree structure speeds up searching through the list and allows inserting and deleting entries without too much data churn.
It is unclear what you mean by a "real object". The index keys are certainly real, and they are stored in the index. But if you mean the whole table row, that is only referenced from the index.
QUESTION
I have a table like this:
...ANSWER
Answered 2021-May-18 at 12:32CREATE PROCEDURE get_childs ()
BEGIN
CREATE TABLE get_childs_tmp(id INT UNIQUE, level INT) ENGINE = Memory;
INSERT INTO get_childs_tmp SELECT child, 0 FROM test WHERE child = parent;
REPEAT
INSERT IGNORE INTO get_childs_tmp
SELECT test.child, get_childs_tmp.level + 1
FROM get_childs_tmp
JOIN test ON test.parent = get_childs_tmp.id;
UNTIL !ROW_COUNT() END REPEAT;
SELECT * FROM get_childs_tmp WHERE level > 0;
DROP TABLE get_childs_tmp;
END
QUESTION
In a CS exam on database systems, a question was asked what the maximum number of block access are to find a record in a given system using a B-tree for indexing. The order of the B-tree was 4, and maximum number of entries is when all internal nodes are half full (because if they are less than half full they will merge with neighbor). Thus the tree is at its highest depth when each node has 2 subtree pointers (and max number of accesses is equal to the depth of the tree). But this would effectively give the tree the same structure as a binary tree as each node simply holds one piece of data and two pointers.
So the question is this:
With the policies for insertion and deletion, is it physically possible to insert and delete nodes in a sequence that allows the tree to take this form, or will it always merge and reduce the depth of the tree?
...ANSWER
Answered 2021-May-05 at 21:25Sure this is possible.
It is not possible to achieve such a binary tree with only insertions, but once you have inserted a bunch of keys (data elements) in a 4-degree b-tree, you can delete keys from the leaves so to target the binary tree shape.
You would target a certain tree height for the binary tree, so first make enough insertions to get a B-tree having that height. Then eliminate keys such to reduce the degree of the nodes that are not binary, starting at the top layers of the tree, working your way down.
An exampleLet's say you want to create such a tree with height 3. For that we will insert value 1 to 13 into an empty tree. This will lead to this tree:
QUESTION
This the C++ code for the sweeping line algorithm that I am using. I am using HeapSort to sort the points. But I am getting the below 2 errors:
Line 214: Char 5: error: no matching function for call to 'heapSort'
...ANSWER
Answered 2021-Apr-29 at 15:05The function heapSort
is declared like
QUESTION
A bit of a newbie to computing science.
I have the basics for a binary tree in Python:
...ANSWER
Answered 2021-Apr-29 at 06:53Add spaces before every (
like this
QUESTION
Data.Tree
uses a list to represent the subtree rooted at a particular node. Is it possible to have two tree types, for example one which uses a list and another which uses a vector? I want to be able to write functions which don't care how the sub-tree is represented concretely, only that the subtree is traversable, as well as functions which take advantage of a particular subtree type, e.g. fast indexing into vectors.
It seems like type families would be the right tool for the job, though I've never used them before and I have no idea how to actually define the right family.
If it matters, I'm not using the containers library tree instance, but instead I have types
data Tree a b = Node a b [Tree a b] deriving (Show, Foldable, Generic)
and
data MassivTree a b = V a b (Array B Ix1 (MassivTree a b))
where the latter uses vectors from massiv.
...ANSWER
Answered 2021-Apr-22 at 12:02You could use a typeclass - in fact the typeclass you need probably already exists.
Consider this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install B-Tree
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page