# sorting

Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter. Eric Raymond

## Merge sort

Language Java | Level Intermediate | Category Algorithms | August 2, 2015 8:39 pm

### Algorithm Problem Description

Merge sort is a divide and conquer and comparison-based sorting algorithm. It divide the array into subarray and conquer by recursively sorting two subarrays. It combines the results into the final array.

#### Dive

Divide the problem into small subproblems.

#### Conquer

Solve the subproblem using recursive function.

#### Combine

Combine the sub solution into solution.

Merge sort can be implemented the Top-down or Bottom-up approach. Top down merge sort split the list into sub list and sort the sub list. Finally, it merge sorted sublist into single sorted list. Bottom up merge sort treats array of sub list and iteratively merges sub-lists back and forth between two buffers. Merge sort uses for linked list sorting, external sorting on the tab. It is stable sort compare then another sorting algorithm.

Write a program to take the un-sorted array and sort the array using Merge sort.

### Output

```

Unsorted array before sorting: [12, 11, 13, 5, 6, 7]
Sorted array After Merge sort sorting: [5, 6, 7, 11, 12, 13]

```