Last active
April 28, 2020 08:52
-
-
Save sebastianfdez/9131a921602f0c5068e86b3c67ea81c2 to your computer and use it in GitHub Desktop.
Basic class of a BTree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* btree namespace. | |
* @type {BTree} | |
*/ | |
export default class BTree { | |
constructor(order) { | |
/** @type {number} */ | |
this.order = order; | |
/** | |
* Root node of the tree. | |
* @type {BTreeNode} | |
*/ | |
this.root; | |
} | |
/** | |
* Search a value in the Tree and return the node. O(log N) | |
* @param {number} value | |
* @returns {BTreeNode} | |
*/ | |
searchValue(value) { | |
/** | |
* Deletes the value from the Tree. O(log N) | |
* @param {number} value | |
*/ | |
delete(value) {} | |
/** | |
* Delete a value from a node | |
* @param {BTreeNode} node | |
* @param {number} value | |
*/ | |
deleteFromNode(node, value) {} | |
/** | |
* Transfer one value from the origin to the target. O(1) | |
* @param {BTreeNode} origin | |
* @param {BTreeNode} target | |
*/ | |
transferValue(origin, target) {} | |
/** | |
* Mix 2 nodes into one. O(1) | |
* @param {BTreeNode} origin | |
* @param {BTreeNode} target | |
*/ | |
mergeNodes(origin, target) {} | |
/** | |
* Insert a new value in the tree O(log N) | |
* @param {number} value | |
*/ | |
insert(value) {} | |
/** | |
* Insert a value in a not-full node. O(1) | |
* @param {BTreeNode} node | |
* @param {number} value | |
*/ | |
insertNonFull(node, value) {} | |
/** | |
* Divide child node from parent into parent.values[pos-1] and parent.values[pos] | |
* O(1) | |
* @param {BTreeNode} child | |
* @param {BTreeNode} parent | |
* @param {number} pos | |
*/ | |
split(child, parent, pos) {} | |
/** | |
* Insert a value in a not-full node. O(1) | |
* @param {BTreeNode} node | |
* @param {number} value | |
*/ | |
insertNonFull(node, value) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment