CSC/MAT 208 (Spring 2024)

Lab: Graph Complexity

In class, we introduced the basic definitions of Big-O notation which forms the basis for the study of the complexity of algorithms. Today, we’ll use Big-O to understand an intuitive, yet frequently inefficient class of algorithms.

Problem: Brute-force

Many algorithms in computing can be classified as combinatorial algorithms. To develop a combinatorial problem for a problem, we must cast that problem as a search for an object of interest from among a finite set of possibilities. Thus, we can think of the algorithm as a search procedure that moves through the space of possibilities in as efficient of a manner as possible.

If there are a finite number of possibilities, then one simple class of combinatorial algorithms are brute-force algorithms where we ignore efficiency and simply try all possible possibilities in some systematic fashion. While seemingly inelegant, sometimes brute-force solutions are the more pragmatic approach—and sometimes even more efficient in real-world settings! However, in many other cases, it is precisely avoiding brute-force search that is the purpose of the algorithm we develop for a task at hand.

Each of the following situations describes a problem that can be recast as a combinatorial algorithm. For each situation:

Note that some of the situations described below come from our previous lab on graph problems

  1. Finding the smallest element among \(n\) elements of an array.
  2. Finding a path between points \(u\) and \(v\) in a simple graph \(G = (V, E)\).
  3. Determining whether the \(n\) elements of an array are in sorted order.
  4. Given a bipartite graph \(G = (V, E)\) with \(V_1, V_2 \subseteq V\) forming a partition of \(V\) and a matching \(M \subseteq E\), determining whether \(M\) is a perfect matching.
  5. Given a bipartite graph \(G = (V, E)\) with \(V_1, V_2 \subseteq V\) forming a partition of \(V\) and a matching \(M \subseteq E\), determine whether \(G\) has a perfect matching.
  6. Given a simple \(G = (V, E)\), determine whether \(G\) has a \(k\)-coloring.