1
-
Six vertices, where each has degree 3.
graph { rankdir=LR a--b,c,d c--d e--f b--c,e d--f e--f } -
Six vertices and four edges.
graph { rankdir=LR a--b,c,d,e f--b,c,d,e e--b,b c--d,d } -
Four edges, and four vertices of degrees respectively. This is not possible as if we add up the degrees of the four vertices, , we need edges to represent all the connections between the vertices. But this is a contradiction the statement says we must use four edges.
[[Handshaking Theorem]] $$ \Sum 1,2,3,4 = \frac{10}{2} = 5 \text{ edges at minimum} $$
2
Hamiltonian:
- Not Hamiltonian:
3
Look at all the vertices of degree :
- Consider the length of the path between the vertices of degree
- to is length
- to is length
- to $
Acceptable invariants:
- : One path of length .
- : Path of length .
Mapping to :
4
- Root:
- Internal:
- Leaves:
- has no children
- Parent of is
- Siblings of are:
- Ancestors of are:
- Descendants of are:
5
- Construct a BST for the given words.
graph { node[shape=plain] null2,null4,null5,null6,null7[label=""] old old--never,programmers never--die programmers--null2,they they--their,null4 die--null5,just just--null6,lose lose--null7,memories } - How many comparisons are required to find or add:
lose: comparisons to findjava: comparisons to add
6
- Pre-order traversal:
- In-order traversal:
- Post-order traversal: