K: 5 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

K: 5

Description:

For every node v, the search key in v is greater than or equal to those in the children of v ... All keys smaller than the root are stored in the left subtree ... – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 18
Provided by: khalru
Category:
Tags: keys

less

Transcript and Presenter's Notes

Title: K: 5


1
K 5
P 9
K1
K 8
P2
P 6
K 7
P 4
2
K 5
P 9
K1
K 8
P2
P 6
Is the treap a heap?
K 7
P 4
3
P 9
P2
P 6
For every node v, the search key in v is greater
than or equal to those in the children of v
P 4
4
K 5
P 9
K1
K 8
P2
P 6
Not a complete tree! NO!
K 7
P 4
5
K 5
P 9
K1
K 8
P2
P 6
Is the treap a Binary Search Tree?
K 7
P 4
6
K 5
K1
K 8
BST? Yes!
K 7
7
K 5
K1
K 8
All keys smaller than the root are stored in the
left subtreeAll keys larger than the root are
sorted in the right subtree
K 7
8
(K, P) (5,9) (7,4) (8,6) (1,2)
K 5
K 8
K 7
K1
P 9
P2
P 6
P 4
9
(K, P) (5,9) (7,4) (8,6) (1,2)
K 5
P 9
K 8
P 6
K 7
P 4
K1
P2
10
K 5
P 9
K 8
P 6
K 7
P 4
K1
P2
11
K 5
P 9
K 8
P 6
K 7
P 4
K1
P2
12
K 5
P 9
K1
K 8
P2
P 6
Assume no duplicate key / priority, only one
treap is possible
K 7
P 4
13
(2,5) (5,2) (3,1) (4,7) (9,4) (8,3)
K2
K5
K3
K4
K9
K8
P5
P2
P1
P7
P4
P3
14
Arrange from left to right,
Smallest key? Biggest key
K9
K8
K5
K4
K2
K3
P4
P3
P2
P7
P5
P1
15
K4
P7
K2
Without destroying left to right
arrangement, Shift the nodes up and down
P5
K9
P4
Biggest priority
K8
P3
Smallest priority
K5
P2
K3
P1
16
K4
P7
K2
P5
K9
P4
K8
P3
K5
P2
K3
P1
17
K4
P7
K9
K2
P4
P5
K8
K3
P3
P1
K5
P2
Write a Comment
User Comments (0)
About PowerShow.com