Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please provide full Java source code for the task along with step-by-step explanation. Using Java Recursive Graphics Write a program that can create an H-tree
Please provide full Java source code for the task along with step-by-step explanation.
Using Java Recursive Graphics 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 itStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started