Question: I'm using this divide-and-conquer algorithm to find the maximum element in an array. How is this any better or different from just using a brute-force

 I'm using this divide-and-conquer algorithm to find the maximum element in

I'm using this divide-and-conquer algorithm to find the maximum element in an array. How is this any better or different from just using a brute-force algorithm?

public class mergesortAlgorithm int[] A = int max; {2 , 4 , 11 , 1 , 6, 7, 9, 100); static static public static void main(String[] args) max= findMax(0, A. ength-1); System.out.println(max); public static int findMax(int a, int b)1 if(b-a 1){ == return Math.max(A[a],A[b]); if(a=-b){ return ALa]; else return Math.max(findMax(a, (a+b)/2), findMax(Ca+b)/2 + 1, b))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!