CS 50 Homework 13 (Section 1 — Prof. Marshall)

Due by class time Tuesday, May 7 (NO EXTENSIONS!)
  1. Complete the BraceMatcher program from part 5 of Lab14.
    Files to submit: BraceMatcher.java

  2. Complete the Mazerunner program from parts 6-7 of Lab14. Your program should display the final path from start to finish, in addition to the positions that were explored.
    Files to submit: Maze.java, Mazerunner.java, Position.java

  3. Study the code for the BinarySearchTree.java data structure discussed in lecture. Note that this version allows duplicate elements to appear in a tree (see the insert method for details). Compile and run TestTree.java. On a piece of paper, draw the final tree that results from performing the insert operations in the order shown in the TestTree program.

  4. Complete the following BinarySearchTree method definitions, using BinarySearchTree.java and TestTree.java as your starting point. Add some code to TestTree to test out your new methods.
    Files to submit: BinarySearchTree.java, TestTree.java.


EXTRA CREDIT

  1. Programming Exercise P16.7 (page 679). Name your class Polynomial, and provide a test program called TestPoly that clearly demonstrates its behavior.
    Files to submit: Polynomial.java, TestPoly.java

  2. Add a method printTree to the BinarySearchTree class that prints the tree as a tree shape (minus the lines between nodes). You can print the tree sideways, with the root node at the left. For a real challenge, display the tree upright with the root node centered at the top.

Turning in Your Homework

Write out your answer to part 3 on paper and turn this in during class. For the rest, put the specified files into a single folder named Your Name HW 13 and drop this folder into the drop box. If you are an off-campus student, you may copy your folder to a CLEAN floppy disk (one containing no other files or folders), and hand this in at the beginning of class, instead of using the drop box.