ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
Selection.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*---------------------------- File Selection.h ----------------------------*/
3
/*--------------------------------------------------------------------------*/
48
/*--------------------------------------------------------------------------*/
49
/*----------------------------- DEFINITIONS --------------------------------*/
50
/*--------------------------------------------------------------------------*/
51
52
#ifndef __ADS_Selection
53
#define __ADS_Selection
54
/* self-identification: #endif constant */
55
56
/*--------------------------------------------------------------------------*/
57
/*------------------------------ INCLUDES ----------------------------------*/
58
/*--------------------------------------------------------------------------*/
59
60
#include "
ADS/Contract.h
"
61
#include "
ADS/sort/InsertionSort.h
"
62
#include "
ADS/sort/QuickSort.h
"
63
64
#include <algorithm>
65
#include <cstddef>
66
#include <random>
67
#include <utility>
68
#include <vector>
69
70
/*--------------------------------------------------------------------------*/
71
/*--------------------------- NAMESPACE ------------------------------------*/
72
/*--------------------------------------------------------------------------*/
73
74
namespace
ADS
75
{
76
103
template
<
class
T ,
class
R = std::mt19937 >
104
T
selection
( std::vector< T > & A , std::size_t k , R * rng =
nullptr
);
105
137
template
<
class
T >
138
T
medianOfMedians
( std::vector< T > & A , std::size_t k );
139
140
/*--------------------------------------------------------------------------*/
141
142
}
// end( namespace ADS )
143
144
/*--------------------------------------------------------------------------*/
145
/*-------------------------- IMPLEMENTATION --------------------------------*/
146
/*--------------------------------------------------------------------------*/
147
148
#include "ADS/search/impl/Selection.tpp"
149
150
/*--------------------------------------------------------------------------*/
151
152
#endif
/* Selection.h included */
153
154
/*--------------------------------------------------------------------------*/
155
/*-------------------------- End File Selection.h --------------------------*/
156
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
InsertionSort.h
Insertion Sort (section 2.7.2), as one sorts a hand of cards: is inserted in the sorted prefix ,...
QuickSort.h
Quicksort (section 12.2): partition(), the perno() of the book, rearranges around the pivot ,...
ADS::medianOfMedians
T medianOfMedians(std::vector< T > &A, std::size_t k)
the item of rank , , in linear time in the worst case
ADS::selection
T selection(std::vector< T > &A, std::size_t k, R *rng=nullptr)
the item of rank , , of (the selezione() of the book); with a generator the pivots are random,...
ADS
Definition
ADT.h:96
ADS
search
Selection.h
Generated by
1.17.0