Error Log

Projekt Ref
1122
Ort
Stockholm
Omfattning
100%
Startdatum
2025-05-16
Slutdatum
Tills vidare
Kontaktperson
paritosh.arya@regent.se

B-Tree in Data Structures and Algorithms (DSA)

A B-Tree is a self-balancing search tree that maintains sorted data and allows efficient insertion, deletion, and search operations. It is commonly used in database systems and file systems for its ability to handle large volumes of data and maintain balance.

Key Properties of a B-Tree:

  1. Order (m):

    • The maximum number of children a node can have is defined by the order mm.

    • A B-Tree of order mm can have a maximum of m−1m-1 keys in a node.

  2. Height-Balanced:

    • All leaf nodes are at the same level, ensuring the tree remains balanced.

  3. Key Constraints:

    • Each node (except the root) must have at least ⌈m/2⌉−1\lceil m/2 \rceil - 1 keys.

    • The root node must have at least 1 key.

  4. Sorted Keys:

    • Keys in each node are sorted in ascending order.

    • All keys in the left subtree of a node are smaller, and all keys in the right subtree are larger.

  5. Dynamic Size:

    • B-Trees adjust their structure dynamically as keys are inserted or deleted, ensuring balance is maintained.


Operations in a B-Tree:

  1. Search:

    • Similar to binary search, but applied within nodes and across child pointers.

    • Time complexity: O(log⁡n)O(\log n), where nn is the number of keys.

  2. Insertion:

    • A new key is inserted into the appropriate node while maintaining the B-Tree properties.

    • If a node overflows (exceeds m−1m-1 keys), it is split into two nodes, and the middle key is promoted to the parent.

    • If the root overflows, a new root is created, increasing the tree height.

  3. Deletion:

    • A key can be deleted directly if it exists in a leaf node.

    • If the key is in an internal node, it is replaced with its in-order predecessor or successor from the child.

    • Nodes may merge if they fall below the minimum required keys, maintaining balance.

Ansök

Projekt Ref
1122
Ort
Stockholm
Omfattning
100%
Startdatum
2025-05-16
Slutdatum
Tills vidare