lec17 - Static Dictionaries Collection of items. Each item...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Static Dictionaries Collection of items. Each item is a pair. (key, element) Pairs have different keys. Operations are: initialize/create get (search) Each item/key/element has an estimated access frequency (or probability). Consider binary search tree only.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example Key Probability a 0.8 b 0.1 c 0.1 a < b < c Cost = 0.8 * 2 + 0.1 * 1 + 0.1 * 2 = 1.9 Cost = 0.8 * 1 + 0.1 * 2 + 0.1 * 3 = 1.2
Background image of page 2
Search Types Successful. Search for a key that is in the dictionary. Terminates at an internal node. Unsuccessful. Search for a key that is not in the dictionary. Terminates at an external/failure node. f 0 a b c f 1 f 2 f 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Internal And External Nodes A binary tree with n internal nodes has n + 1 external nodes. Let s 1 , s 2 , …, s n be the internal nodes, in inorder. key(s 1 ) < key(s 2 ) < … < key(s n ) . Let key(s 0 ) = –infinity and key(s n+1 ) = infinity . Let f 0 , f 1 , …, f n be the external nodes, in inorder. f i is reached iff key(s i ) < search key < key(s i+1 ) . f 0 a b c f 1 f 2 f 3
Background image of page 4
Cost Of Binary Search Tree Let p i = probability for key(s i ) .
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

lec17 - Static Dictionaries Collection of items. Each item...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online