Here you can find the source of mergeSorted(float[] a, int alen, float b[], int blen)
public static float[] mergeSorted(float[] a, int alen, float b[], int blen)
//package com.java2s; public class Main { public static float[] mergeSorted(float[] a, int alen, float b[], int blen) { float[] answer = new float[alen + blen]; int i = 0, j = 0, k = 0; while (i < alen && j < blen) { if (a[i] < b[j]) answer[k++] = a[i++];/* w w w .j a v a 2 s .c o m*/ else answer[k++] = b[j++]; } while (i < alen) answer[k++] = a[i++]; while (j < blen) answer[k++] = b[j++]; return answer; } public static float[] mergeSorted(float[] a, float b[]) { float[] answer = new float[a.length + b.length]; int i = 0, j = 0, k = 0; while (i < a.length && j < b.length) { if (a[i] < b[j]) answer[k++] = a[i++]; else answer[k++] = b[j++]; } while (i < a.length) answer[k++] = a[i++]; while (j < b.length) answer[k++] = b[j++]; return answer; } public static double[] mergeSorted(double[] a, double b[]) { double[] answer = new double[a.length + b.length]; int i = 0, j = 0, k = 0; while (i < a.length && j < b.length) { if (a[i] < b[j]) answer[k++] = a[i++]; else answer[k++] = b[j++]; } while (i < a.length) answer[k++] = a[i++]; while (j < b.length) answer[k++] = b[j++]; return answer; } public static double[] mergeSorted(double[] a, double b[], double[] store) { int i = 0, j = 0, k = 0; while (i < a.length && j < b.length) { if (a[i] < b[j]) store[k++] = a[i++]; else store[k++] = b[j++]; } while (i < a.length) store[k++] = a[i++]; while (j < b.length) store[k++] = b[j++]; return store; } }