# Algorithms_in_C++: sorting/non_recursive_merge_sort.cpp File Reference

Loading...
Searching...
No Matches
non_recursive_merge_sort.cpp File Reference
`#include <cstddef>`
`#include <iostream>`
`#include <utility>`
Include dependency graph for non_recursive_merge_sort.cpp:

## Namespaces

namespace | sorting
| for working with vectors

## Functions

template<class Iterator >
void | sorting::merge (Iterator l, Iterator r, const Iterator e, char b[])
| merges 2 sorted adjacent segments into a larger sorted segment More...
template<class Iterator >
void | sorting::non_recursive_merge_sort (const Iterator first, const Iterator last, const size_t n)
| bottom-up merge sort which sorts elements in a non-decreasing order More...
template<class Iterator >
void | sorting::non_recursive_merge_sort (const Iterator first, const size_t n)
| bottom-up merge sort which sorts elements in a non-decreasing order More...
template<class Iterator >
void | sorting::non_recursive_merge_sort (const Iterator first, const Iterator last)
| bottom-up merge sort which sorts elements in a non-decreasing order More...
int | main (int argc, char **argv)

## Detailed Description

Copyright 2020

Author
  Albirair

A generic implementation of non-recursive merge sort.

## Function Documentation

## main()

int main | ( | int | argc,
|  | char ** | argv
| ) |  |

{
int size;
std::cout << "Enter the number of elements : ";
std::cin >> size;
int* arr = new int[size];
for (int i = 0; i < size; ++i) {
std::cout << "arr[" << i << "] = ";
std::cin >> arr[i];
}
non_recursive_merge_sort(arr, size);
std::cout << "Sorted array\n";
for (int i = 0; i < size; ++i)
std::cout << "arr[" << i << "] = " << arr[i] << '\n';
delete[] arr;
return 0;
}
std::cin
std::cout
sorting::non_recursive_merge_sort
void non_recursive_merge_sort(const Iterator first, const Iterator last, const size_t n)
bottom-up merge sort which sorts elements in a non-decreasing order
Definition: non_recursive_merge_sort.cpp:25