Top Banner

of 18

GraphPresentation

Apr 04, 2018

Download

Documents

nagarajuvcc123
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/29/2019 GraphPresentation

    1/18

    Definition assumes external nodes(extended m-way search tree).

    B-tree of orderm.

    m-way search tree.

    Not empty => root has at least 2 children.

    Remaining internal nodes (if any) have at

    least ceil(m/2) children.External (or failure) nodes on same level.

    Definition Of B-Tree

  • 7/29/2019 GraphPresentation

    2/18

    2-3 And 2-3-4 Trees

    B-tree of order m. m-way search tree.

    Not empty => root has at least 2 children.

    Remaining internal nodes (if any) have atleast ceil(m/2) children.

    External (or failure) nodes on same level.

    2-3 tree is B-tree of order 3.

    2-3-4 tree is B-tree of order 4.

  • 7/29/2019 GraphPresentation

    3/18

    Insert

    15 20

    8

    4

    1 3 5 6 30 409

    Insertion into a full leaf triggers bottom-up node

    splitting pass.

    16 17

  • 7/29/2019 GraphPresentation

    4/18

    Split An Overfull Node

    aiis a pointer to a subtree.

    piis a dictionary pair.

    m a0 p1 a1 p2 a2pm am

    ceil(m/2)-1 a0 p1 a1 p2 a2pceil(m/2)-1 aceil(m/2)-1

    m-ceil(m/2) aceil(m/2) pceil(m/2)+1 aceil(m/2)+1pm am

    pceil(m/2)plus pointer to new node is inserted in

    parent.

  • 7/29/2019 GraphPresentation

    5/18

    Insert

    15 20

    8

    4

    1 3 5 6 30 409

    Insert a pair with key = 2.

    New pair goes into a 3-node.

    16 17

  • 7/29/2019 GraphPresentation

    6/18

    Insert Into A Leaf 3-node Insert new pair so that the 3keys are in

    ascending order.

    Split overflowed node around middle key.

    1 2 3

    Insert middle key and pointer to new node

    into parent.

    1 3

    2

  • 7/29/2019 GraphPresentation

    7/18

    Insert

    15 20

    8

    4

    1 3 5 6 30 409

    Insert a pair with key = 2.

    16 17

  • 7/29/2019 GraphPresentation

    8/18

    Insert

    15 20

    8

    4

    5 6 30 409 16 17

    31

    2

    Insert a pair with key = 2plus a pointer into parent.

  • 7/29/2019 GraphPresentation

    9/18

    Insert

    Now, insert a pair with key = 18.

    15 20

    8

    1

    2 4

    5 6 30 409 16 173

  • 7/29/2019 GraphPresentation

    10/18

    Insert Into A Leaf 3-node Insert new pair so that the 3keys are in

    ascending order.

    Split the overflowed node.

    16 17 18

    Insert middle key and pointer to new node

    into parent.

    1816

    17

  • 7/29/2019 GraphPresentation

    11/18

    Insert

    Insert a pair with key = 18.

    15 20

    8

    1

    2 4

    5 6 30 409 16 173

  • 7/29/2019 GraphPresentation

    12/18

    Insert

    Insert a pair with key = 17plus a pointer into parent.

    15 20

    8

    1

    2 4

    5 6 30 4093

    18

    16

    17

  • 7/29/2019 GraphPresentation

    13/18

    Insert

    Insert a pair with key = 17plus a pointer into parent.

    8

    1

    2 4

    5 6 30 4093 16

    17

    15

    18

    20

  • 7/29/2019 GraphPresentation

    14/18

    Insert

    Now, insert a pair with key = 7.

    1

    2 4

    5 6 30 4093 16

    15

    18

    20

    8 17

  • 7/29/2019 GraphPresentation

    15/18

    Insert

    Insert a pair with key = 6plus a pointer into parent.

    30 401

    2 4

    93 16

    15

    18

    20

    8 17

    5

    7

    6

  • 7/29/2019 GraphPresentation

    16/18

    Insert

    Insert a pair with key = 4plus a pointer into parent.

    30 401 93 16

    15

    18

    20

    8 17

    6

    4

    2

    5 7

  • 7/29/2019 GraphPresentation

    17/18

    Insert

    Insert a pair with key = 8plus a pointer into parent.

    There is no parent. So, create a new root.

    30 401

    93

    16

    15

    18

    20

    6

    8

    2

    5 7

    417

  • 7/29/2019 GraphPresentation

    18/18

    Insert

    Height increases by 1.

    30 401 93 16

    15

    18

    2062

    5 7

    4 17

    8