{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

14. BinarySearchTrees_outside

Sorted sequence we store the items in an array based

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

View Full Document Right Arrow Icon
sorted sequence We store the items in an array-based sequence, sorted by key We use an external comparator for the keys Performance: get , floorEntry and ceilingEntry take O (log n ) time, using binary search get takes O ( n ) time since in the worst case we have to shift n / 2 items to make room for the new item erase take O ( n ) time since in the worst case we have to shift n / 2 items to compact the items after the removal The lookup table is effective only for dictionaries of small size or for dictionaries on which searches are the most common operations, while insertions and removals are rarely performed (e.g., credit card authorizations) © 2010 Goodrich, Tamassia
Background image of page 4

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

View Full Document Right Arrow Icon
5 Binary Search Trees A binary search tree is a binary tree storing keys (or key-value entries) at its internal nodes and satisfying the following property: Let u , v , and w be three nodes such that u is in the left subtree of v and w is in the right subtree of v . We have key ( u ) key ( v ) key ( w ) External nodes do not store items An inorder traversal of a
Background image of page 5
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page4 / 10

sorted sequence We store the items in an array based...

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

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