CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree...

49
CS302 - Data Structures using C++ Kostas Alexis Topic: Balanced Search Trees - Introduction

Transcript of CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree...

Page 1: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

CS302 - Data Structuresusing C++

Kostas Alexis

Topic: Balanced Search Trees - Introduction

Page 2: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

2-3 Trees

• General Search Tree

• Interior nodes are either 2-nodes or 3-nodes

• 2-node has one data item and two children

• 3-node has two data items and three children• Simple implementations may use 3-nodes for both

Page 3: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

2-3 Trees

• General Search Tree

• Interior nodes are either 2-nodes or 3-nodes

• 2-node has one data item and two children

• 3-node has two data items and three children• Simple implementations may use 3-nodes for both

50

leftChild rightChild

data

60|90

leftChild rightChildmiddleChild

small|large data

Page 4: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

2-3 Trees

• General Search Tree

• Interior nodes are either 2-nodes or 3-nodes

• 2-node has one data item and two children

• 3-node has two data items and three children• Simple implementations may use 3-nodes for both

50

leftChild rightChild

data

60|90

leftChild rightChildmiddleChild

<50 >50

<60 >90>60,<90

small|large data

Page 5: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

2-3 Trees

• General Search Tree

• Interior nodes are either 2-nodes or 3-nodes

• 2-node has one data item and two children

• 3-node has two data items and three children• Simple implementations may use 3-nodes for both

• Are never taller than minimum-height binary tree

• A 2-3 tree with n nodes never has height greater than log2(𝑛 + 1)

50

leftChild rightChild

data

60|90

leftChild rightChild

small|large data

middleChild

<50 >50

<60 >90>60,<90

Page 6: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

2-3 Trees

60

30 90

10 50

20 40

80 95

70

A Balanced Binary Search Tree

50

30 70 | 90

40 60 9580

2-3 Tree with the same elements

10 | 20

Page 7: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

2-3 Trees

60

30 90

10 50

20 40

80 95

70

A Balanced Binary Search Tree – Height = 4

50

30 70 | 90

40 60 9580

2-3 Tree with the same elements – Height = 3

10 | 20

Page 8: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

Page 9: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20

Page 10: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30

Page 11: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40

Page 12: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50

Page 13: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50 60

Page 14: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50 60 70

Page 15: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50 60 70

Page 16: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50 60 70 80

Page 17: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50 60 70 80

Page 18: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50 60 70 80 90

Page 19: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Traversing 2-3 Trees

• To traverse a 2-3 Tree• Perform the analogue of an in-order traversal

• Leftmost subtree,

• Left value,

• Center subtree,

• Right value,

• Rightmost subtree

• Searching a 2-3 tree is as efficient assearching the shorted binary tree (withthe same values)

• 𝑂(log2𝑛)

50

30 70 | 90

40 60 958010 | 20

10 20 30 40 50 60 70 80 90 95

Page 20: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

Page 21: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

Page 22: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

• Inserting a value into a 2-node turns it into a 3-node

Page 23: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

• Inserting a value into a 2-node turns it into a 3-node

• Inserting a value into a 3-node causes it todivide

• Result is a subtree of 2-nodes

Page 24: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

• Inserting a value into a 2-node turns it into a 3-node

• Inserting a value into a 3-node causes it todivide

• Result is a subtree of 2-nodes

50 70 90

50

Page 25: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

• Inserting a value into a 2-node turns it into a 3-node

• Inserting a value into a 3-node causes it todivide

• Result is a subtree of 2-nodes

50 70 90

50 | 70

Page 26: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

• Inserting a value into a 2-node turns it into a 3-node

• Inserting a value into a 3-node causes it todivide

• Result is a subtree of 2-nodes

50 70 90

50 | 70 | 90

Page 27: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

• Inserting a value into a 2-node turns it into a 3-node

• Inserting a value into a 3-node causes it todivide

• Result is a subtree of 2-nodes

50 70 90

70

50 90

Page 28: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• Inserting values into a 2-3 Tree• Always insert values into an EXISTING leaf

• Only exception – root (first value)• Create a 2-node and insert value

• Inserting a value into a 2-node turns it into a 3-node

• Inserting a value into a 3-node causes it todivide

• Result is a subtree of 2-nodes

50 70 90

70

50 90

• To insert an item with key k into a 2-3 tree• Locate the leaf at which the search for k would terminate• Insert the new item k into the leaf

• If the leaf now contains only two items – done

• If the leaf now contains three items, split the leaf into two nodes and move the

middle value into parent

Page 29: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• When an internal node contains three items• Split the node into two nodes

• Accommodate the node’s children

• When the root contains three items• Split the root into two nodes

• Create a new root node

• Tree grows in height

Page 30: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• When an internal node contains three items• Split the node into two nodes

• Accommodate the node’s children

• When the root contains three items• Split the root into two nodes

• Create a new root node

• Tree grows in height

Page 31: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• When an internal node contains three items• Split the node into two nodes

• Accommodate the node’s children

• When the root contains three items• Split the root into two nodes

• Create a new root node

• Tree grows in height

20

50

30

80

25

60

50

Order of Values Given

20 90 30 80 25 60 50

Page 32: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• When an internal node contains three items• Split the node into two nodes

• Accommodate the node’s children

• When the root contains three items• Split the root into two nodes

• Create a new root node

• Tree grows in height

20

50

30

80

25

60

50

Order of Values Given

20 90 30 80 25 60 50

20

Page 33: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• When an internal node contains three items• Split the node into two nodes

• Accommodate the node’s children

• When the root contains three items• Split the root into two nodes

• Create a new root node

• Tree grows in height

20

50

30

80

25

60

50

Order of Values Given

20 90 30 80 25 60 50

20 | 90

Page 34: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• When an internal node contains three items• Split the node into two nodes

• Accommodate the node’s children

• When the root contains three items• Split the root into two nodes

• Create a new root node

• Tree grows in height

20

50

30

80

25

60

50

Order of Values Given

20 90 30 80 25 60 50

30

20 90

Page 35: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Adding to 2-3 Trees

• When an internal node contains three items• Split the node into two nodes

• Accommodate the node’s children

• When the root contains three items• Split the root into two nodes

• Create a new root node

• Tree grows in height

20

50

30

80

25

60

50

Order of Values Given

20 90 30 80 25 60 50

30 | 80

20 | 25 50 | 60 90

Page 36: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

Page 37: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

30 70 | 90

10 | 20 40 60 80 95

Page 38: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

30 70 | 90

10 | 20 40 60 80 95

Page 39: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

30 70 | 90

10 40 60 80 95

Page 40: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

30 70 | 90

10 40 60 80 95

Page 41: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

30 70 | 90

10 40 80 95

Page 42: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

30 90

10 40 70 | 80 95

Page 43: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

30 90

10 40 70 | 80 95

Page 44: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

40 90

10 30 70 | 80 95

Page 45: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50

90

10 | 40 70 | 80 95

Page 46: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50 90

10 | 40 70 | 80 95

Page 47: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50 | 90

10 | 40 70 | 80 95

Page 48: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Removing From a 2-3 Tree

• Removing values from 2-3 trees• Always remove from a leaf

• Values (and children) will be redistributed

• Nodes can be merged

• Only root node is deleted• And only if it is empty (contains no values)

50 | 90

10 | 40 70 | 80 95

Page 49: CS302 – Data Structures - Autonomous Robots Lab...Traversing 2-3 Trees •To traverse a 2-3 Tree •Perform the analogue of an in-order traversal • Leftmost subtree, • Left value,

Thank you