Trees, Binary Search Trees, Lab 7, Project 2
Trees, Binary Search Trees, Lab 7, Project 2
3
What
is
the
depth
of
D?
2
What
is
the
height
of
C?
2
What
is
the
height
of
B?
1
What
is
the
height
of
the
tree?
3
What
nodes
make
up
A’s
right
subtree?
BINARY
SEARCH
TREES
Binary
Search
Trees
• A
tree
with
the
property
that
the
value
of
all
descendants
of
a
node’s
leY
subtree
are
smaller,
and
the
value
of
all
descendants
of
a
node’s
right
subtree
are
larger
BST
Example
BST
OperaGons
• insert(item)
– Add
an
item
to
the
BST
• remove(item)
– Remove
an
item
from
the
BST
• contains(item)
– Test
whether
or
not
the
item
is
in
the
tree