File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+ class minmax
3+ {
4+ void divide (int a [],int start ,int end )
5+ {
6+ if (start ==end )
7+ {
8+ min =a [start ];
9+ max =a [start ];
10+ }
11+ else
12+ {
13+ int m1 ,m2 ;
14+ mid =(start +end )/2 ;
15+ divide (a ,start ,mid )
16+ m1 =min ;
17+ m2 =max ;
18+ divide (a ,mid +1 ,end )
19+ if (m1 <min )
20+ m1 =min ;
21+ if (m2 >max )
22+ m2 =max ;
23+ }
24+ System .out .println ("Minimum value in the given Array elements is:" +min ); System .out .println ("Maximum value in the given Array elements is:" +max );
25+ }
26+ }
27+ class Dd
28+ {
29+ public static void main (String y [])
30+ {
31+ Scanner s =new Scanner (System .in );
32+ minmax mm =new minmax ();
33+ int a []=new int [50 ];
34+ System .out .println ("Enter the Total:" );
35+ int n =s .nextInt ();
36+ System .out .println ("Enter the Array elements:" );
37+ for (int i =0 ;i <n ;i ++)
38+ a [i ]=s .nextInt ();
39+ mm .divide (a ,0 ,n -1 );
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments