Skip to content

abranhe/mergesort.c

Repository files navigation




mergesort.c: Merge Sort algorithm library in C



In computer science, merge sort is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output.

Installation

Installing using Clib

$ clib install abranhe/mergesort.c

Usage

#include "mergesort.h"

int main()
{
	int arr[] = {10, 7, 12, 27, 30};

	mergeSort(arr, 0, 5);
	// 7 10 12 27 30
}

See a real example.

API

void mergeSort(arr, first, last);

Implement merge sort.

Params:
  • array: unsorted Array
  • first: first element of the array to start sorting
  • last: last element of the array to finish sorting

Team

Carlos Abraham Logo
Carlos Abraham

License

MIT License © Carlos Abraham