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: 50% (2 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...
-
In an Otto cycle, the compression ratio is 10 . The temperature at the beginning of compression and at the end of heat supply is 300 and \(1600 \mathrm{~K}\), respectively. Assume, \(\gamma=1.4\) and...
-
A rectangular wire loop enclosing an area \(A=0.40 \mathrm{~m}^{2}\) is inside a long cylindrical solenoid with two windings per \(\mathrm{mm}\). The area vector of the loop is aligned with the axis...
-
Consider the following time series data Using the nave method (most recent value) as the forecast for the next week, compute the following measures of forecast accuracy: a. Mean absolute error b....
-
1. Identify the product which represents the solid state in the above reaction. a) Barium chloride b) Barium sulphate c) Sodium chloride d) Sodium sulphate 2. The colour of the solution observed...
-
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...
-
Florence Industries Ltd, based in Alberta, manufactures household cleaning products. Its president, Ebenezer, entered into negotiations with Second Class Disposal Services Inc for a contract to...
-
1. Show that for any m by k matrix A and k by n matrix B, |AB||||A||FB||F, where ||||F is the Frobenius norm (See Tut1 Q2). This is Tut1 Q2: 2. Let A = (a) be an m by n matrix, define the Frobenius...
-
You have a fairly strong investment portfolio (see amounts and Beta values below). However, a new opportunity has presented itself and you are unsure if it is worth the investment. a) Given that the...
-
The interest rate is 5 percent. Assuming you only care about the present value, then you would be equally happy if you received a gift of either $100 today or a gift of Hint: calculate the present...
-
a person has won $500 000. They invest it at 12% compounded semi-annually. They decide to live off the investment, withdrawing an amount every six months. Determine how much money they can withdraw...
-
The following accounts and balances (in thousands) were extracted from the financial statements included in the 2022 10k of ABC, Inc. The company's average tax rate is 30%. Cash $8,000 Cost of goods...
-
Color-Dyne printed patterns on carpets. After reviewing the companys audited financial statements, the plaintiff s provided materials to Color-Dyne on credit. These financial statements showed that...
-
Define cultural intelligence. Cite the books or journal articles you found in Capella's library. Explain why cultural intelligence is important for HR practitioners and other organizational managers.
-
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.
-
Develop a Java program to implement a binary search algorithm.
-
) Normalize the following wavefunctions: a. y=e -x 4 b. =sin y =sin() x=- to y=0 to 2 2 dt=4xdx
-
(10 pts) 2D box problems with equal length sides = a: a. For a particle in a 2D box in the xy plane, provide contour plots to illustrate the wave function and the probability density for the 4,3...
Study smarter with the SolutionInn App