Question 2

Part (A) and (B)

^2967d7

Question 3

Part (a) Prove: A graph is a tree is acyclic and has edges (where is the number of vertices).

We use induction on (the number of vertices).

Part 1: (Tree Acyclic and )

  • Base Case (): A single vertex is a tree, is acyclic, and has edges. The statement holds.

  • Inductive Hypothesis: Assume every tree with vertices is acyclic and has edges.

  • Inductive Step (): Let be a tree with vertices. A tree always has at least one leaf (a vertex with degree 1). Remove a leaf vertex and its connecting edge. This creates a new graph .

    • is still a tree (removing a leaf can’t create a cycle or disconnect a connected graph).
    • has vertices.
    • By the inductive hypothesis, has edges.
    • had one more edge than , so has edges. Since , has edges.

Part 2: (Acyclic and Tree)

We need to show that if a graph is acyclic and has edges, it must be connected (and therefore a tree). We prove this by contradiction.

  • Base Case (): a single vertex is connect.

  • Inductive Hypothesis: Assume every graph with vertices and is acyclic and has edges is connected.

  • Inductive Step (): Let acyclic with vertices. Suppose G is not connected.

    • Then, has multiple connected components: (where , since it’s disconnected).
    • Each is acyclic (a subgraph of an acyclic graph is acyclic).
    • Let be the number of vertices in component , and be the number of edges. Note, that .
    • Because each is acyclic and connected, by apply the part 1, .
    • The total number of edges in is the sum of the edges in each component: .
    • Since (disconnected), . This means .
    • But we started by assuming has edges (). We have a contradiction. Our assumption that is disconnected is false.
  • Therefore, must be connected. Since is acyclic and connected, it’s a tree.

Conclusion: We’ve shown both directions, so the statement is proven. A graph is a tree if and only if it is acyclic and has edges.

Part (B)

Question 5

Part (a)

Transclude of Eular,-Hamilton-Cycles;-Planer-Graph;-Coloring#5be995

Part (B)

^2497b4

Question 6

Part (a)

AGT Complete, p.53

Part (b)

^826ced

Question 7

Part (a)

^0c4fca

Part (B)

^19910a

Question 8

Part (a)

Dijkstra’s Algorithm

Merits:

  • Efficiency: For graphs with non-negative edge weights, Dijkstra’s algorithm is very efficient, typically having a time complexity of using a priority queue, where is the number of vertices and the number of edges.
  • Optimal Solution: It guarantees finding the shortest path from a source node to all other nodes in the graph if all edge weights are non-negative.

Demerits:

  • Negative Edge Weights: Dijkstra’s algorithm fails to find the correct shortest paths when the graph contains negative edge weights. It may get stuck in an infinite loop or produce incorrect results.
  • Single Source: The algorithm can only find the shortest path from the chosen source to every other node.

Example (Merit): Consider a graph where nodes represent cities and edges represent road distances (all positive). Dijkstra’s can efficiently find the shortest route from a starting city to all other cities.

Example (Demerit): Suppose there are nodes representing locations. There is an edge with a cost of -5. If we try to run Dijkstra’s, it may not output the most optimal path.

Bellman-Ford Algorithm

Merits:

  • Negative Edge Weights: Bellman-Ford can handle graphs with negative edge weights, unlike Dijkstra’s algorithm.
  • Negative Cycle Detection: It can detect the presence of negative-weight cycles, which are cycles where the sum of edge weights is negative.

Demerits:

  • Efficiency: Bellman-Ford is generally less efficient than Dijkstra’s for graphs with non-negative weights. Its time complexity is .
  • Single Source: Similar to Dijkstra, the algorithm can only find the shortest path from a source to every other node.

Example (Merit): Consider a graph representing currency exchange rates. Some rates might represent a loss (negative edge). Bellman-Ford can find the most profitable exchange sequence or detect arbitrage opportunities (negative cycles). Example (Demerit): Given the city example again, for only non-negative edges, the Bellman Ford algorithm will run slower.