/merge-sort

The code implements the Merge Sort algorithm in C++, which uses the "divide and conquer" technique to recursively break down a given array or list into smaller sub-arrays and then merge them back together in sorted order.

Primary LanguageC++MIT LicenseMIT

Merge Sort Algorithm in C++

License: MIT

This C++ code implements the Merge Sort algorithm, which uses the "divide and conquer" technique to recursively break down a given array or list into smaller sub-arrays and then merge them back together in sorted order.

To use the code, simply input an array of doubles and it will be sorted using the Merge Sort algorithm. The sorted array will then be printed to the console.

The code defines two functions - merge() and mergeSort() - which handle the merging and sorting operations, respectively. The merge() function merges two sorted sub-arrays into a single sorted array, while the mergeSort() function recursively divides the array into smaller sub-arrays and calls the merge() function to merge them back together in sorted order.

Table of Contents

Input

The code takes an array of doubles as input and sorts it using the Merge Sort algorithm.

Output

The sorted array is then printed to the console.

Test

To test this algorithm run compiler and then copy in terminal:

./main < Act-1-1-caso-1.txt

Functions

The code defines two functions - merge() and mergeSort() - which handle the merging and sorting operations, respectively.

The merge() function merges two sorted sub-arrays into a single sorted array, while the mergeSort() function recursively divides the array into smaller sub-arrays and calls the merge() function to merge them back together in sorted order.

License

This code is released under the MIT License. See LICENSE.md for more information.

Questions

If you have any questions about the repository, open an issue or contact any of us contributors in https://github.com/leogzz0/merge-sort