Merge Sort using C Program




Merge sort

  • Merge sort algorithm is one of two important divide-and-conquer sorting algorithms (the other one is quick sort).Merge
  • MergeIt is a recursive algorithm.Merge
    • MergeDivides the list into halves,Merge
    • MergeSort each halve separately, andMerge
    • MergeThen merge the sorted halves into one sorted array.Merge

In this lesson we will learn how to write a source code in C programming language for doing simple Merge sort using array in ascending order.

Question : Write a c program for Merge sort.

Merge Sort  C Example :

Analysis of Merge 

Merging two sorted arrays of size kMerge

  • Best-case: Merge
    • MergeAll the elements in the first array are smaller (or larger) than all the elements in the second array.Merge
    • MergeThe number of moves: 2k + 2k Merge
    • MergeThe number of key comparisons: kMerge
  • Worst-case: Merge
    • MergeThe number of moves: 2k + 2k Merge
    • MergeThe number of key comparisons: 2k-1Merge

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com