CS 361: Algorithms and Data Structures
Homework 1
Due date: Monday 9/14 in class



Assignments will be collected at the beginning of the class period. Please bring a hardcopy to turn in. Your assignment can be hand-written or typed.

Textbook questions [30 points]
  1. [15 pts] IA 2.1-3
  2. [15 pts] IA 2.2-3

Additional question [20 points]
In this course, we will be studying many different types of algorithms. It is important that you understand how the algorithms we cover in class fit within the larger field of Algorithms. To this end, consider the following high-level classification scheme for algorithms:
  1. Exact algorithms: An exact algorithm produces a provably correct, or optimal, output for all valid inputs.

  2. Approximation algorithms: An approximation algorithm produces a nearly-correct, or nearly-optimal, output for all valid inputs.

  3. Inductive algorithms: An inductive algorithm produces a correct, or optimal, solution for nearly all valid inputs.

Note the difference between approximation algorithms and inductive algorithms. Approximation algorithms produce a nearly correct output for all inputs whereas inductive algorithms produce a correct output for nearly all inputs.

All of the algorithms we cover in this class will be exact algorithms! Selection sort is an example of an exact algorithm. We showed, using loop invariants, that selection sort correctly sorts an array of numbers.

At the end of the semester, we will learn about NP-complete problems which (informally) are problems that take too long to solve optimally. Many algorithms for NP-complete problems are approximation algorithms: it may take too long to find an optimal solution, but finding a nearly-optimal solution is quite feasible.

Finally, there are inductive algorithms. This question asks you to apply what you've learned so far about exact algorithms (i.e. the characteristics of an algorithm, input size, running time) to inductive algorithms.

Consider the following problem: Given two newspaper articles, determine whether the articles discuss the same news event. The input is the text of both articles. The output is a yes/no decision.

  • [5 pts] Propose an algorithm to solve the above problem. Your algorithm does not need to be provably correct. However, your algorithm should be (1) thoughtful, (2) well-defined, and (3) computational. Provide both pseudocode and a 1-paragraph description of your algorithm.

  • [5 pts] Thinking about your algorithm, what is a natural way to represent/express the input size?

  • [5 pts] What is the running time of your algorithm in terms of your proposed input size from the previous question? Justify your answer

  • [5 pts] Finally, for inductive algorithms, it makes more sense to talk about "accuracy" than correctness. Accuracy is the percentage of all possible inputs for which your algorithm produces a correct output. How could you measure/determine the accuracy of your algorithm?


Last modified: Fri Jan 24 10:58:47 PST 2014