TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation of the DNF sort implementation. More...
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <vector>
Go to the source code of this file.
Namespaces | |
namespace | sorting |
for working with vectors | |
namespace | dnf_sort |
Functions for the DNF sort implementation. | |
Functions | |
template<typename T > | |
std::vector< T > | sorting::dnf_sort::dnfSort (const std::vector< T > &in_arr) |
The main function implements DNF sort. | |
static void | test () |
Self-test implementations. | |
int | main () |
Main function. | |
Implementation of the DNF sort implementation.
C++ program to sort an array with 0, 1 and 2 in a single pass(DNF sort). Since one traversal of the array is there hence it works in O(n) time complexity.
Definition in file dnf_sort.cpp.
std::vector< T > sorting::dnf_sort::dnfSort | ( | const std::vector< T > & | in_arr | ) |
The main function implements DNF sort.
T | type of array |
a | array to be sorted, |
arr_size | size of array |
Definition at line 39 of file dnf_sort.cpp.
int main | ( | void | ) |
Main function.
Definition at line 109 of file dnf_sort.cpp.
|
static |
Self-test implementations.
Definition at line 74 of file dnf_sort.cpp.