34int keys [] = { 36, 32, 4, 12, 52, 59, 2, 2, 26, 1 };
43# define LLINK(i, n) (2*i)
44# define RLINK(i, n) (2*i + 1)
91 cerr <<
"Error: n must be a positive integer." <<
endl;
104 unsigned int i, value;
106 for (i = 0; i < n; i++)
110 cout << value <<
" ";
128 for (i = 1; i <= heap.
size(); i++)
129 cout << heap[i] <<
" ";
133 for (i = 0; i < n; i++)
136 cout << value <<
" ";
143 int *
array1 =
new int [n];
145 int *
array2 =
new int [n];
147 for (
int i = 0; i < n; i++)
154 for (
int i = 0; i < n; i++)
163 for (
int i = 0; i < n; i++)
Fixed-capacity binary heap backed by a raw array.
T & insert(const T &key)
Insert an element into the heap.
T getMin()
Remove the smallest element in the heap and return a copy of its value.
constexpr size_t size() const noexcept
Return the number of elements currently stored.
Main namespace for Aleph-w library functions.
void heapsort(T *array, const size_t n, const Compare &cmp=Compare())
Sort an array using the heapsort algorithm.
void faster_heapsort(T *array, const size_t n, const Compare &cmp=Compare())
Optimized version of heapsort.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Fixed-capacity binary heap and heapsort algorithms.