On this page:
1 Big-O Drills
2 Addition Algorithms
3 Crossword Puzzle Algorithm
4 Paths With Distance

Homework 11

Last updated: Mon, 5 Dec 2022 23:02:50 -0500

Out: Tue Dec 06, 00:00 EST Due: Mon Dec 12, 23:59 EST

This assignment begins to explore time complexity.

Homework Problems

  1. Big-O Drills (6 points)

  2. Addition Algorithms (4 + 4 + 4 = 12 points)

  3. Crossword Puzzle Algorithm (11 points)

  4. Paths With Distance (10 points)

  5. README (1 point)

Total: 40 points

Submitting

Submit your solution to this assignment in Gradescope hw11. Please assign each page to the correct problem and make sure your solutions are legible.

A submission must also include a README containing the required information.

1 Big-O Drills

Answer true or false for each statement below.

You may give an extra explanation if you think it would help clarify your answer.

  1. 1000 = O(n^3)

  2. 1000n^3 = O(n^3)

  3. n^3 = O(n^6)

  4. 1000^n = 2^{O(n)}

  5. 1000\log n = O(\log n)

  6. n\log n = O(\log n)

2 Addition Algorithms

This problem is about addition of two binary numbers. In this problem, let n be the length of the input, which is the number of digits in the numbers. (You may assume that the input numbers have the same number of digits.)

  1. Give a "brute force" algorithm for adding two binary numbers. Show that the time complexity of this algorithm is exponential in the length of the input.

  2. Now show that the elementary school addition algorithm you learned as a child is in \textbf{P}.

  3. Finally, show that if we instead use unary numbers (instead of binary), the same algorithm will be exponentially slower.

3 Crossword Puzzle Algorithm

The New York Times website has a daily "mini" crossword puzzle that has at most 5 rows and 5 columns.

  1. Come up with a "brute force" algorithm for solving this puzzle and compute the run time of your solution. You may assume the alphabet for filling in the crossword is \left\{\texttt{A},\ldots,\texttt{Z}\right\}.

  2. Explain why (surprisingly) this problem is in \textbf{P}!

4 Paths With Distance

In class we learned about the \textit{PATH} problem (see also Sipser Thm 7.14) for unweighted graphs.

We now change the problem to use weighted graphs. More specifically, let a weighted directed graph be a pair (V,E) where V is a set of vertices and E is a set of weighted edges where each edge is a triple (u,v,wgt) where u and v are vertices and wgt is a weight value.

Now define \textit{PATH}_{wgt} = \left\{\left\langle G,s,t,k\right\rangle\mid G\textrm{ is a graph with directed path from }s\textrm{ to }t\textrm{ with distance } \leq k\right\}

You may assume that the weights in the graph represent distances.

Show that \textit{PATH}_{wgt} is in \textbf{P}.