Question: (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
Get step-by-step solutions from verified subject matter experts
