For Monday after Spring Break Read Weiss, chapter 5, sections 1-4 - - PowerPoint PPT Presentation

for monday after spring break
SMART_READER_LITE
LIVE PREVIEW

For Monday after Spring Break Read Weiss, chapter 5, sections 1-4 - - PowerPoint PPT Presentation

For Monday after Spring Break Read Weiss, chapter 5, sections 1-4 Homework: Chapter 4, exercises 19 and 27 Paper 1 Any questions? Splay Trees Interested in the cost of a sequence of search operations rather than the cost of a


slide-1
SLIDE 1

For Monday after Spring Break

  • Read Weiss, chapter 5, sections 1-4
  • Homework:

– Chapter 4, exercises 19 and 27

slide-2
SLIDE 2

Paper 1

  • Any questions?
slide-3
SLIDE 3

Splay Trees

  • Interested in the cost of a sequence of

search operations rather than the cost of a single search.

  • We want to make sure that the amortized

cost of M search operations is M log N.

slide-4
SLIDE 4

Basic Idea

  • When we find a node, we’re going to rotate

it to the top in a way that helps to balance the tree if it is currently unbalanced.

slide-5
SLIDE 5

Cases

  • Found node has no grandparent: rotate node

and root

  • Found node has a grandparent:

– zig-zig case (parent is same side of grandparent that node is of root): rotate node and grandparent – zig-zag case (node’s value is in-between value

  • f parent and grandparent): do a standard AVL

double rotation

slide-6
SLIDE 6

Comparison

  • Splay trees and AVL trees
slide-7
SLIDE 7

External Dictionaries

  • We’ve talked so far about dictionaries small

enough to reside in memory

  • However, many applications require dictionaries

much larger than will easily fit in memory

  • Biggest issue for external dictionaries is the

number of disk accesses required for an operation

  • Each disk access retrieves a block of memory
slide-8
SLIDE 8

m-way Search Trees

  • Empty tree
  • r
  • Each internal node has up to m children and

between 1 and m-1 elements

  • A node with p elements has exactly p+1

children

  • Elements are ordered
slide-9
SLIDE 9

B-tree of Order m

  • an m-way search tree
  • If non-empty

– The root has at least two children – All internal nodes other than the root have at least ceiling of m/2 children. – All external nodes are at the same level

  • Thus we have guarantees on the height of

the tree

  • Book technically covers structure called

B+-tree—items in internal nodes also appear in external nodes

slide-10
SLIDE 10

Operations

  • Searching
  • Insertion
  • Deletion