ADS
Algorithms and Data Structures
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"
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
74namespace ADS
75{
76
103template< class T , class R = std::mt19937 >
104T selection( std::vector< T > & A , std::size_t k , R * rng = nullptr );
105
137template< class T >
138T 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/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Insertion Sort (section 2.7.2), as one sorts a hand of cards: is inserted in the sorted prefix ,...
Quicksort (section 12.2): partition(), the perno() of the book, rearranges around the pivot ,...
T medianOfMedians(std::vector< T > &A, std::size_t k)
the item of rank , , in linear time in the worst case
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,...
Definition ADT.h:96