Modify Htree (Program 2.3.4) to animate the drawing of the (mathrm{H})-tree. Next, rearrange the order of the
Question:
Modify Htree (Program 2.3.4) to animate the drawing of the \(\mathrm{H}\)-tree. Next, rearrange the order of the recursive calls (and the base case), view the resulting animation, and explain each outcome.
Transcribed Image Text:
Program 2.3.4 Recursive graphics public class Htree { } public static void draw(int n, double size, double x, double y) { // Draw an H-tree centered at x, y // of depth n and given size. if (n = 0) return; double x0 = x - size/2, x1 = x + size/2; double yo y size/2, y1 = y + size/2; StdDraw. line(x0, y, x1, y); StdDraw. line (x0, y0, x0, y1); StdDraw. line(x1, yo, x1, yl); draw(n-1, size/2, x0, y0); draw(n-1, size/2, x0, y1); draw(n-1, size/2, x1, y0); draw(n-1, size/2, x1, yl); } public static void main(String[] args) { } int n = Integer.parseInt (args [0]); draw(n, 0.5, 0.5, 0.5); size- ,{x, y1) n size x, y (x, y) (x0, y0) depth line length center (x1, y1) (x1, y0)
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (3 reviews)
To animate the drawing of the Htree we can introduce a delay after each drawing of the individual lines In Java you can use StdDrawpauseint t where t ...View the full answer
Answered By
Carly Cimino
As a tutor, my focus is to help communicate and break down difficult concepts in a way that allows students greater accessibility and comprehension to their course material. I love helping others develop a sense of personal confidence and curiosity, and I'm looking forward to the chance to interact and work with you professionally and better your academic grades.
4.30+
12+ Reviews
21+ Question Solved
Related Book For
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne
Question Posted:
Students also viewed these Algorithm Design questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
In this question assume that p and q are atomic formulae. (a) Compare and contrast path formulae and state formulae in temporal logic. [4 marks] (b) Describe and contrast the meanings of F(G p) and...
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
The balance sheet data for Alans Lightworks, Corp., at August 31, 2012, and September 30, 2012, follow: Requirement 1. The following are three independent assumptions about the business during...
-
The value of the z-score in a hypothesis test is influenced by a variety of factors. Assuming that all other variables are held constant, explain how the value of z is influenced by each of the...
-
How does C support relational and Boolean expressions?
-
Marlowe Corporation is considering investing in a new facility. The estimated cost of the facility is \($1,931,000\). It will be used for 12 years, then sold for \($600,000\). The facility will...
-
Marathon, Inc., manufactures two types of shoes: X-Trainer and Court. Last year, Marathon had the following costs and revenues: Marathon, Inc., currently uses labor costs to allocate all overhead,...
-
2. Which sequence of rigid motions will definitely work to take triangle GHJ onto triangle STU? A A. Rotate GHJ using center G until GH is lined up with ST and then reflect over aline halfway between...
-
Write a data type Point that implements the following API: public class Point Point (double x, double y) double distanceTo (Point q) String toString() Euclidean distance between this point and q...
-
In thinking about the appropriate balance between the market and the government in achieving sustainability, do you think the government needs to take a stronger role or would you favor reducing...
-
P(x, 5, z) is on al line through Q(2, -4, 3) that is parallel to one of the coordinate axes. Which axis must it be and what are x and z?
-
Possible impacts of climate change on transport and how CO2 emissions could be reduced from the freight transport sector. Can climate change block international maritime traffic?
-
Describe some challenges that project managers face when executing information technology projects. 2. Describe some benefits of a life-cycle management process for the acquisition of computers....
-
Convert the following FA to RE using Ardens theorem. 90 1 0,1 92
-
Suppose you have been tasked with investigating attitudes about climate change. The survey includes lifestyle questions, attitude questions, demographics, and opinion questions specific to greenhouse...
-
Evaluate the impact of the organizational structure and challenges on driving results from a strategic perspective. Evaluate the impact of the organizational structure on driving results from an...
-
Ed Hanson is the controller of Caseys Collectibles. The business uses the accrual method of accounting and recognizes sales revenue in the period in which the sale is made. As a result, the Accounts...
-
During 2012, Cheng Book Store paid $483,000 for land and built a store in Georgetown. Prior to construction, the city of Georgetown charged Cheng $1,300 for a building permit, which Cheng paid. Cheng...
-
Bsed on the following query: SELECT EMP_LNAME, EMP_FNAME, EMP_AREACODE, EMP_SEX FROM EMPLOYEE WHERE EMP_SEX = F AND EMP_AREACODE = 615 ORDER BY EMP_LNAME, EMP_FNAME; What is the likely data sparsity...
-
What are scripts, and how are they created in ColdFusion?
-
Describe the basic services provided by the ColdFusion Web application server.
-
During Heaton Company's first two years of operations, it reported absorption costing net operating income as follows: Sales (@ $62 per unit) Year 1 Year 2 $ Cost of goods sold (@ $43 per unit) Gross...
-
1. The numbers in cells B18 to B20 should be formulas that refer to B15. This allows the number of cases to be changed in cell 815 with the other cells changing automatically. Exce2. The formula in...
-
Based on the following transactions, answer the following questions. i. Purchased inventory with a cost of $28,300 on account. ii. Sales on account to customers totalled $54,700. iii. Payments made...
Study smarter with the SolutionInn App