## 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 <:= 2^{h+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 log_{2} (n+1) - 1.

**Pf**: 2^{h+1} >= n + 1

h+1 >= log_{2} (n+1)

h >= log_{2} (n+1) - 1

and since h is an integer, h >= [ log_{2} (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(log_{2} (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 2^{h} leaves.

**Theorem 3.22**: Any algorithm for sorting p >= 4 items by pairwise comparison requires in the worst
case cp log_{2} 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 log_{2}(p!). Now,

p! >= p(p-1)(p-2)...( [p/2]^ ) >= (p/2)^{p/2}

log_{2} (p!) >= p/2 (log_{2} (p/2)) = (p/2)(log_{2} p - log_{2} 2) = (p/2)(log_{2} p - 1).

Since p >= 4,

log_{2} p >= 2 or ½ log_{2} p >= 1. So, log_{2} p - 1 >= log_{2} p - ½ log_{2} p = ½ log_{2} p.

Therefore,

log_{2} (p!) >= (p/2)(log_{2} p - 1) >= (p/2) ½ log_{2} p = p/4 log_{2} p.

*Bubble Sort* - complexity O(p^{2}).

### Representing graphs on Computers

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