Answered step by step
Verified Expert Solution
Question
1 Approved Answer
of integers in O(n. Open with Problem 4. (25 points) Games Jordon, a reputed police inspector is friends with the local vigilante Matban. Matban has
of integers in O(n. Open with Problem 4. (25 points) Games Jordon, a reputed police inspector is friends with the local vigilante Matban. Matban has given him the Mat Signal to call him in case of emergency. The signal is supposed to be put on top of a roof. Since Vigilantes are looked down upon by the government, Games cannot put it on the police building 2 CS-1205 Test 1 Games wants to put the signal on a random building and control it using a remote control from a different building's roof. We represent the heights of the buildings in this city as an array of n distinct integers, A[O] - A[n - 1]. Assume that these heights are all distinct, and that n is a power of 2. Games needs to choose 2 of these buildings to use. To be able to use the controller, no other building should block the signal between the remote and the Mat Signal. Precisely, in the array A, he must find a contiguous subarray A[i]... AL] for integers i,, (0 sis; 2 allow Games to use the buildings if and only if their largest two elements are the two endpoints. For example, if the array is 14.1.2.5,3,7,6 Games can use buildings 4 and 5 (having length 4) or buildings 5 and 7 (having length 3). In this problem, you'll develop a divide-and-conquer algorithm to find Games a line of sight of maximum possible length. (a) [10 points) Suppose you split array A into two halves. Ao = A[0: n/2 and A, = A[n/2 n), and suppose that the longest line of sight has one endpoint eo in Ao and one endpoint e, in A. Let e = min(co, e) be the smaller endpoint. Prove that e = max(A). (b) [15 points) Describe an efficient divide-and-conquer algorithm to find Games the farthest away buildings in a given input array Aloe n of n distinct integers. (For any algorithm you describe in this class, you should argue that it is correct, and argue its running time.) For full points, your algorithm should have a worst-case running time of O(nlogn). Problem -5. [10 points) are not supposed to solve of integers in O(n. Open with Problem 4. (25 points) Games Jordon, a reputed police inspector is friends with the local vigilante Matban. Matban has given him the Mat Signal to call him in case of emergency. The signal is supposed to be put on top of a roof. Since Vigilantes are looked down upon by the government, Games cannot put it on the police building 2 CS-1205 Test 1 Games wants to put the signal on a random building and control it using a remote control from a different building's roof. We represent the heights of the buildings in this city as an array of n distinct integers, A[O] - A[n - 1]. Assume that these heights are all distinct, and that n is a power of 2. Games needs to choose 2 of these buildings to use. To be able to use the controller, no other building should block the signal between the remote and the Mat Signal. Precisely, in the array A, he must find a contiguous subarray A[i]... AL] for integers i,, (0 sis; 2 allow Games to use the buildings if and only if their largest two elements are the two endpoints. For example, if the array is 14.1.2.5,3,7,6 Games can use buildings 4 and 5 (having length 4) or buildings 5 and 7 (having length 3). In this problem, you'll develop a divide-and-conquer algorithm to find Games a line of sight of maximum possible length. (a) [10 points) Suppose you split array A into two halves. Ao = A[0: n/2 and A, = A[n/2 n), and suppose that the longest line of sight has one endpoint eo in Ao and one endpoint e, in A. Let e = min(co, e) be the smaller endpoint. Prove that e = max(A). (b) [15 points) Describe an efficient divide-and-conquer algorithm to find Games the farthest away buildings in a given input array Aloe n of n distinct integers. (For any algorithm you describe in this class, you should argue that it is correct, and argue its running time.) For full points, your algorithm should have a worst-case running time of O(nlogn). Problem -5. [10 points) are not supposed to solve<><>
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