Graph Theory Lecture Notes 8

Search Trees

Def: Rooted Tree, height, level, offspring (descendents)

Def: m-ary tree, binary search tree

Ex:

Lemma: If T is a binary tree with n vertices and height h, then n <:= 2h+1 - 1.

Pf: Count the number of vertices by level.

Theorem 3.19: The minimum height of a binary search tree with n vertices is log2 (n+1) - 1.

Pf: 2h+1 >= n + 1
h+1 >= log2 (n+1)
h >= log2 (n+1) - 1
and since h is an integer, h >= [ log2 (n+1)]^ - 1. (where [ ... ]^ means round up to the next integer).

Cor: The computational complexity of a file search using a binary search tree is O(log2 (n+1)).

Sorting

Def: Decision Tree

In a decision tree, the leaves are outputs which are orderings of the inputs. So, for p inputs there must be at least p! leaves.

Theorem 3.21: A binary tree of height h has at most 2h leaves.

Theorem 3.22: Any algorithm for sorting p >= 4 items by pairwise comparison requires in the worst case cp log2 p comparisons, for c a positive constant.

Pf: Since there must be at least p! leaves, the height of the decision tree is at least log2(p!). Now,
p! >= p(p-1)(p-2)...( [p/2]^ ) >= (p/2)p/2
log2 (p!) >= p/2 (log2 (p/2)) = (p/2)(log2 p - log2 2) = (p/2)(log2 p - 1).
Since p >= 4,
log2 p >= 2 or ½ log2 p >= 1. So, log2 p - 1 >= log2 p - ½ log2 p = ½ log2 p.
Therefore,
log2 (p!) >= (p/2)(log2 p - 1) >= (p/2) ½ log2 p = p/4 log2 p.

Bubble Sort - complexity O(p2).

Representing graphs on Computers

Def: Adjacency matrix, Incidence Matrix, Arc List, Adjacency Structure