Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(30 pts.) Runtime analysis of recursive algorithms Recursive algorithms can be useful for generating objects with fractal structure, like realistic rocky terrain. We can store
(30 pts.) Runtime analysis of recursive algorithms Recursive algorithms can be useful for generating objects with fractal structure, like realistic rocky terrain. We can store the shape of the ground as an (n+1)(n+1) array of height values, so that H[x][y] is the height at point (x,y). Suppose the desired heights at the corners (0,0), (0,n), (n,0), and (n,n) have been given, and we need to fill in the rest of the grid. Consider the following algorithm, which is a simplified version of a terrain generation algorithm used in practice. The function RAND() returns a random number in constant time. function MIDPOINTDISPLACEMENT(H,n) FILLINSQUARE(H,0,n,0,n) function FILLINSQUARE(H,2,1,1,b) # Fill in the part of H between the given left, right, top, and bottom indices. if r-
Step 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