CSCI 255 Fall 2013
Introduction to Algorithms and Discrete Structures
Archived Class
Charles Cusack
Computer Science
Hope College



CSCI 125
CSCI 255
MATH 341


Homework 17


  • Most problems are found in one of the following:
    1. ADM: The Algorithm Design Manual
    2. IDMA: An Introduction to Discrete Mathematics and Algorithms
  • For full credit, provide context for each problem, show all calculations, and justify all answers by providing enough comments to explain your reasoning.
  • You will lose a significant amount of credit if you do not provide context, calculations, and justifications for a problem.
  • Numbers and/or algebra by themselves are not enough. A correct answer with no justification will be worth no more than half credit, and sometimes much less than that.
  • Precision is very important. You cannot skip steps, make guesses, or use flawed logic. Any of these things can lead to incorrect answers.
  • Homework assignments must be very neatly written or typeset (e.g. using Word or OpenOffice).
  • You must indicate any assistance/collaboration you had on an assignment as specified on the Policies page.
  • NEW! If a problem asks for an algorithm, you should give the most efficient algorithm you can find to ensure full credit. You should also specify the complexity of the algorithm with justification, whether or not the problem asks for it.


The following problems are from pages 184-189 of ADM.
A few general comments: Part of learning a topic is learning to use the vocabulary. Here are a few examples.

  1. Graphs have vertices/nodes and edges, not elements.
  2. For BFS/DFS, the terms discovered and processed are technically defined, so use those instead of explored, found, visited, seen, etc. which do not have clearly defined meanings.
  3. You can reach the end of a linked list, but you can't reach the end of a tree.
5-1Show your work. In particular, details about the BFS/DFS tree should be given (e.g. parent pointers or the tree drawn on the graph) along with any relevant numbers (e.g. distances and/or timestamps). Essentially, show enough to demonstrate that you actually followed the algorithms. Most of you seem to have ignored these comments. Please include all of the details asked for. Although the book's BFS algorithm does not explicitly compute distances, the version in the lecture notes does, so follow that version if necessary.Computational Problem Rubric
5-3This problem is talking about acyclic graphs, not rooted trees. For the induction step, assume it is true for any tree with n nodes. Then consider a tree with n+1 nodes. How do you get a tree with n nodes from a tree with n+1 nodes so that you can apply the inductive hypothesis? Hint: consider a leaf. You cannot just start with a tree with n nodes and add a leaf to it. The induction step needs to show that it is true for any tree with n+1 nodes, so you need to start with an arbitrary tree with n+1 nodes. Also, when you apply the inductive step, you need to prove that there is exactly one path between every pair of nodes. You need to argue it is true of the (n+1)th node with any other node, but also that it is still true of any pair of nodes not including the (n+1)th.Proof Rubric
5-9Assume the only operators are +, -, /, and *. The easiest way to think about it is to implement it as Eval(node root), where root is the root of the binary tree. It is actually pretty straightforward if you use recursion. You should give your solution as pseudo-code and deal explicitly with the 4 possible operators.Algorithm Rubric
5-21Explain the idea behind your algorithm and justify its complexity. If you use BFS, specify what additional data you need to keep track of and what to do in one or more of the "process" methods of BFS. You will implement this algorithm for Homework 9. Feel free to do so now as a way of testing your algorithm. Your answer can be as simple as something like "For each node keep track of X. Initialize the values to Y. In processXYZ, do Q..."Algorithm Rubric