Insert 20 Splay tree PowerPoint PPT Presentation

presentation player overlay
1 / 5
About This Presentation
Transcript and Presenter's Notes

Title: Insert 20 Splay tree


1
Insert 20 (Splay tree)
Rules from slide 6
50
50
50
25
75
25
75
25
75
2
1
2
100
100
100
10
10
10
1
1
12
14
20
14
12
20
2
14
20
12
1
50
50
20
1
25
75
75
50
20
10
20
100
100
25
10
25
14
75
1
10
2
14
14
12
100
12
12
2
Insert 20 (AVL tree)
50
50
25
75
75
14
100
30
12
25
12
100
10
20
30
10
14
3
Insert 20 (2-4 tree)
10 15 30
5 7
11 12
16 17 25
40
15
17 30
10
5 7
11 12
16
40
20 25
4
What does foo() return? (foo() is for binary
search trees)Answer on next slide
AssumeBSTNodes have members int data BSTNode
parent, left, right
BSTNode foo(BSTNode n) if (n NULL)
return(NULL) if (n.left ! NULL)
return(foo(n.left)) if (n.right NULL)
return(n.parent) return(fee(n.right)) BSTNo
de fee(BSTNode n) if (n.left NULL)
return(n) return(fee(n.left))
5
Answer foo() returns the node with the
second- smallest value in the BST (or NULL
if no such node exists)
Write a Comment
User Comments (0)
About PowerShow.com