









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Jamin; Class: Data Struct&Algor; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Unknown 1989;
Typology: Study notes
1 / 16
This page cannot be seen from the preview
Don't miss anything!










Outline
Last time:
Today:
Binary Search Tree (BST)
What is the difference between a binary tree and a binary search tree?
Definition of BST:
Search algorithm, search for key starting from T.root:
BST Insertion
Insertion of new element:
Given a BST, where are the smallest and largest elements?
How do you remove an element from a BST? Remove z, b, m from the above BST
BST Removal
After removal of a node, tree must remain a BST
Removal of an element elt:
o swap with either the smallest element of Tr or the largest element of Tl
o if elt is now leaf, remove it
o if non-leaf, it should have only one child, replace parent’s pointer to this node with pointer to child and remove the node
Binary Space Partitioning (BSP) Tree
What is a BSP?
A spatial data structure used to help organize geometry in n-dimensional space
Roughly: a BST that sorts objects in space by their coordinates
Used to speed up queries about whether geometric objects overlap or about the spatial ordering of geometric objects
Example uses:
BSP Partitions Space
Blue wants to go to object e. Which objects are in the way?
a
i
m
d c e
b
h
k
j
g
n
l
x=30 1
(^4) x=
(^2) y=
x=52 3 A B
E
C
D
f
BSP Creation
a
i
m
d c e
b
h
k
j
g
n
l
x=30 1
(^4) x=
(^2) y=
x=52 3 A B
E
C
D
f
x=30^1
A a, b , gh, i, j, k y=30^2
E ln x=52^3
B d
D ce m
y=45^4
C f
BSP Found Colliding Object
Blue wants to go to object e. Which objects are in the way?
a
i
m
d c e
b
h
k
j
g
n
l
x=30 1
(^4) x=
(^2) y=
x=52 3 A B
E
C
D
f
x=30^1
A a, b , gh, i, j, k y=30^2
E ln x=52^3
B d
D ce m
y=45^4
C f
Next check for collision against items ’c’ and ’m’
MinHeap
MinHeap: an ordered tree with the following properties:
Binary heap: must be a complete binary tree (see Preiss Fig. 11.4, note that it is not a representation of the ternary tree in Fig. 11.3)
A complete binary tree can be efficiently stored as an array
Binary MinHeap
findmin(): time complexity O( )
enqueue(): must maintain binary heap properties (Fig. 7.6 GTM)
time complexity: O( )
dequeuemin(): (Fig. 7.7 GTM)
time complexity: O( )
Discrete Event Simulations
Most common operations in discrete event simulations (for example, video games):