Posts

Showing posts from January, 2018

Some stuff.

#include <iostream> using namespace std; int a[20000]; bool in_heap[20000]; int n; inline void swap(int& x, int& y) { int tmp = x; x = y; y = tmp; } void maintain(int i) {     /*cout << endl << endl;     cout << "Maintaining node " << i << endl;     cout << "Current heap: ";     cout << a[1];     for(int i = 2; i <= n; i++) cout << ", " << a[i];     cout << endl;*/     while(i < n)     {         int m, c;         /*cout << "\tStats:" << endl;         cout << "\t\tCurrently at node " << i << endl;         cout << "\t\tCurrent node value: " << a[i] << endl;         cout << "\t\tParent: " << i/2 << endl;         cout << "\t\tLeft child: " << 2*i << endl;         cout << "\t\tRight child: " << 2*i