52 try { n =
stoi(
argv[1]); }
catch (...) { n = 1000; }
57 cerr <<
"n must be positive" <<
endl;
61 unsigned int t = std::time(0);
64 try { t =
stoul(
argv[2]); }
catch (...) { t = std::time(0); }
69 cout <<
"testBinHeap " << n <<
" " << t <<
endl;
75 for (i = n - 1; i >= 0; i--)
83 for (i = 0; i < n; i++)
93 for (i = n - 1; i >= 0; i--)
104 for (i = 0; i < n; i++)
113 for (i = n - 1; i >= 0; i--)
122 for (i = 0; i < n/2; i++)
129 for (i = n - 1; i >= 0; i--)
137 for (i = 0; i <= n + n/2; i++)
144 catch (exception & e)
146 cout << e.what() <<
endl;
156 for (i = 2*n - 1; i >= 0; i--)
165 for (i = 0; i < n/2; i++)
180 for (i = 0; i < n/2; i++)
190 while (heap.
size() > 0)
199 for (i = n - 1; i >= 0; i--)
206 for (i = 0; i < n; i++)
214 cout <<
"End" <<
endl;
Core header for the Aleph-w library.
virtual bool verify_heap(Node *p) const
Node * getMin()
Elimina del heap el nodo de menor prioridad.
Node * remove(Node *node)
Elimina del heap el nodo node.
void remove_all_and_delete() noexcept
Borra todos los nodos del heap, invoca a los destructores de los nodos eliminados y libera toda la me...
Node * insert(Node *p) noexcept
Inserta un nodo en un heap.
const size_t & size() const noexcept
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
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.
Node heap without virtual destructor.
BinHeapNode< Key > Node
El tipo de nodo del heap.
static void printNode(BinHeap< int >::Node *node, int, int)
Binary heap implementation using tree structure.
Utility functions for binary tree operations.
Lazy and scalable dynamic array implementation.