The principle and function of java merge sorting algorithm
This article mainly introduces "java merge sort algorithm principle and role", in daily operation, I believe many people in java merge sort algorithm principle and role of the problem there are doubts, small make up all kinds of information, sort out simple and easy to use operation method, hope to answer "java merge sort algorithm principle and role" doubts helpful! Next, please follow the small series to learn together!
1. Definition Merge sort is conceptually the simplest sort algorithm. Like Quick Sort, Merge Sort is based on divide and conquer. Merge sort divides the sequence of elements to be sorted into two subsequences of equal length, sorts each subsequence, and then merges them into a single subsequence. The process of merging two sub-sequences is two-way merging.
Illustrations (from the web)
public class TestController { public static void main(String[] args) { int[] a = { 49, 38, 65, 97, 76, 13, 27, 50 }; mergeSort(a, 0, a.length-1); System.out.println("Arrays.toString(a)); } public static void mergeSort(int [] a,int start,int end){ //End recursion when there is only one element in the subsequence if(start