Question: Please implement using the java code below: import java.io.*; import java.util.*; public class Lab2 { /** * Problem: Use D&C to find the largest rectangular

Please implement using the java code below:
import java.io.*; import java.util.*;
public class Lab2 { /** * Problem: Use D&C to find the largest rectangular area in a histogram in O(n log n) time. */ private static int problem(int[] histogram) { // Implement me! return -1; }
Problem You are given an integer array A of size n; all numbers in A are non-negative. A represents a histogram where each bar has width 1 and the i-th bar has height A[i]. Our goal is to find the area of the largest rectangle in the histogram that is completely covered by bars. Assignment Implement a Divide & Conquer algorithm that solves the problem. In worst case, your implementation should run in O(n log n) time. Clearly state your Divide, Conquer, and Combine phase, as well as your base case. Do not use a segment tree. Note: The runtime requirement is strict. Your algorithm has to run in O(n log n) time even in the very worst case. Hence, spending linear time to find and then splitting at the smallest element will not be fast enough
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
