Tuesday, May 21, 2013

Sort two input arrays in Ascending order and find the median of elements without using any predefined methods of Java

                                 Sorting of array is easy to sort the array in descending order.To sort the array elements  java gives the predefined methods.Sort two input array elements in ascending order without using any predefined methods of Java,this question asked in Cap-Gemini Coding Challenge Test. This program is some what difficult but i have a easy way to write this program.

 Actually Cap-Gemini given this as below:

In Bangalore, Cap-Gemini has departments.Department A has m employees with empNumber and Department B has n employees with empNumber. Combine this two departments into single department and sort the empNumbers  in ascending order. And find the median of employ.
Conditions:
All employees are even number then 
  pos1=(m+n)/2
pos2=(m+n)/2+1
avg=(pos1+pos2)/2
Odd numbers:
 pos=(m+n)/2

   
 Example:
 Input:
           Employ Numbers of Department A={12,6,5,2,3}
           Employ Numbers of Department B={9,5,13,10,1,11}

Output:
           Employees of Department of A following token numbers:12  6 5 2 3
         
           Employees of Department of B following token numbers: 9 5 13 10 1 11
         
           Total Employees=11
     
           Median=9
          
For program click on below link:


No comments:

Post a Comment