![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
#include <cstddef>
#include <iostream>
#include <utility>
Go to the source code of this file.
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 | |
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 | |
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 | |
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 | |
int | main (int argc, char **argv) |
template<class Iterator> | |
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 | |
Copyright 2020
A generic implementation of non-recursive merge sort.
Definition in file non_recursive_merge_sort.cpp.
int main | ( | int | argc, |
char ** | argv ) |
Definition at line 94 of file non_recursive_merge_sort.cpp.
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
sorts elements non-recursively by breaking them into small segments, merging adjacent segments into larger sorted segments, then increasing the sizes of segments by factors of 2 and repeating the same process. best-case = worst-case = O(n log(n))
first | points to the first element |
last | points to 1-step past the last element |
n | the number of elements |
Definition at line 25 of file non_recursive_merge_sort.cpp.