Skip to content

Instantly share code, notes, and snippets.

@banacorn
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banacorn/12a4a98497ea07739a54 to your computer and use it in GitHub Desktop.
Save banacorn/12a4a98497ea07739a54 to your computer and use it in GitHub Desktop.
Trees
  • Leaf: a vertex of degree 1.
  • Tree-graphic: a sequence is said to be tree-graphic if it is a permutation of the degree sequence of a tree.

3.1.1

Every tree with at least 1 edge hase at least 2 leaves.

3.1.2

If the degree of every vertex of a graph is at least 2, then that graph must contain a cycle.

3.1.3

Every tree on n vertices contains exactly n - 1 edges.

3.1.4

A forest G on n vertices has n - 1 - c(G) edges

3.1.5

Any graph G on n vertices has at least n - c(G) egdes

3.1.6

If G is a simple graph with n vertices and k components, then: |EG| <= (n-k)(n-k+1)/2

3.1.7

A simple n-vertex graph with more than (n-1)(n-2)/2 edges must be connected

3.1.8

Let T be a graph with n vertices. Then the following statements are equivalent.

  1. T is a tree
  2. T contains no cycle and has n - 1 edges
  3. T is connected and has n - 1 edges
  4. T is connected, and every edge is a cut-edge
  5. Any two vertices of T are connected by exactly one path
  6. T contains no cycles, and for any new edges e, the graph T + e has exactly one cycle

3.1.9

Let T be a tree with at least 3 vertices. If v is a leaf of T and w is its neightbor, then ecc(v) = ecc(w) + 1. If v is a central vertex of T, then deg(v) >= 2.

3.1.10

Let v and w be two vertices in a tree T such that w is of maximum distance from v (i.e. ecc(v) = d(v, w)). Then w is a leaf

3.1.11

T' be a subtree of T by deleting all its leaves, ecc(v') = ecc(v) - 1 for all vertex v

3.1.12

T' be a subtree of T by deleting all its leaves, Z(T') = Z(T)

3.1.13

The center Z(T) of a tree T is either a single vertex or a single edge

3.1.14

A sequence <d1, d2, ...dn> of n >=2 positive integers is tree-graphic <=> sum of the sequence = 2n - 2

3.1.15

*Let T be any tree on n vertices, and let G be a simple graph such that the minimum degree of the vertices of the graph G >= n - 1 => T is a subgraph of G

  • Directed Tree: a directed graph whose underlying graph is a tree.
  • Rooted Tree: a tree with a designated vertex called the root.
  • Shortest-path Tree for G from v: is a rooted tree T with vertex-set VG and root v such that the unique path in T from v to each vertex w is a shortest path in G from v to w.
  • Depth (or Level): the root has depth 0.
  • Height: greatest depth of a tree.
  • Child, Sibling, Descendant, Ancestor, Leaf, Internal Vertex
  • m-Ary Tree: a rooted tree in which every vertex has m or fewer children.
  • Complete m-Ary Tree: a rooted tree in which every vertex has m children.
  • Isomorphic as Rooted Trees: exists an isomorphism that maps root to root.
  • Ordered Tree: a rooted tree in which the children of each vertex are assigned a fixed ordering.
  • Standard Plane Drawing, Binary Tree, Left Subtree, Right Subtree

3.2.1

A complete m-ary tree has m^k vertices at level k

3.2.2

An m-ary tree has at most m^k vertices at level k

3.2.4

The complete m-ary tree of height t has (m ^ (h + 1) - 1) / (m - 1)

3.2.5

The complete binary tree of height h has 2 ^ (h + 1) - 1 vertices

3.2.6

Every binary tree of height h has at most 2 ^ (h + 1) - 1 vertices

  • Binary Code: an assignment of symbols or other meanings to a set of bitstrings. Each bitstring is reaferred to as a codeword.
  • Prefix Code: a binary code with the property that no codeword is an inital substring of any other codeword.
  • Average Weighted Depth: of the binary tree T, denoted wt(T), is given by a weight wi. is given by wt(T) = sum depth(s) * w
  • Huffman Tree, Huffman Code

3.5.1

If the leaves of a binary tree are assigned weights, and if each internal vertex is assigned a weight equal to the sum of its children's weights, then the tree's average weighted depth equals the sum of the weights of its internal vertices.

3.5.2

For a given list of weights w1, w2, ... , wl, a Huffman tree has the smallest possible average weighted depth among all binary trees whose leaves are assigned those weights.

  • Left-complete: the bottom level has no gaps as one traverses from left to right.
  • Priority Tree: a left-complete binary tree whose vertices have labels (called priorities) from an poset, such that no vertex has higher proirity than its parent.
  • Priority Queue: a set of entries, each of which is assigned a priority. When an entry is to be removed, or dequeued, from the queue, an entry with the highest priority is selected.
  • Heap: a representation of priority tree as an array, having the following address pattern.
    • index root = 0
    • index (leftchild v) = 2 * index v + 1
    • index (rightchild v) = 2 * index v + 2
    • index (parent v) = floor ( index v - 1 / 2 )

  • Prüfer sequence: is of length n - 2, for n >= 2 ...

3.7

The number of n-vertex labeled trees is n ^ (n - 2) for n >= 2

3.7.1

Let dk be the number of occurrences of number k in a Prüfer encoding sequence for a labeled tree T. Then the degree of vertex k in T equals tp dk + 1.

3.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment