COS 126 Recursive Graphics Programming Assignment Due: 11:59pm

Write a program that can create an H-tree pattern, as illustrated below. Then develop a program that prints recursive patterns of your own design.

The H-tree is another example of a fractal pattern like the Koch snowflake and Sierpinski triangle. It also of practical interest in circuit design. For example, imagine that we want to lay out circuit components on a microprocessor chip so that the length of wire connecting each component to the clock is the same. This property is desirable to achieve uniform wiring delay. The H-tree pattern is an elegant solution: position the clock in the center of the biggest H, and put each circuit component at one of the exposed endpoints of the smallest H's.

Part 1.   Though the H-tree pattern looks complex, it can be generated with a short recursive program. Your task is to write a program HTree.java with a recursive function htree and a main driver that calls the recursive function once, and animates the results using StdDraw. Think recursively: your function should draw an H and calls itself 4 times (with an appropriate stopping condition).

Your program will read in a command line parameter N to control the depth of the recursion. First, make sure that your program can draw a single H, with N set to 1. Then, check that it draws five H's with N set to 2. Your program will be nearly (or completely) debugged when you get to this point. Below are the target H-tree patterns with N set to 1, 2, 3, 4, 5 and 6, respectively.

Part 2.   In this part you will create your own recursive design. First, do something different for your basic graphic design. For example, you can have the regions represented by the recursive calls be rectangles of varying size, or you can have them overlap. Or, work with X's or S's instead of H's. Or, use StdDraw.spot to produce filled circles, filled squares, images, or text. Or, use five recursive calls and pentagons, or whatever. Try using color or introducing some randomness. Originality and creativity in the design will be a factor in your grade.

Submission.   Submit the files: HTree.java, Art.java, and readme.txt file. Your program Art.java should take a single command line parameter N that controls the depth of recursion. We will choose N between 1 and 7 to test it.