string Airport::extractMin() { string res = events[0].element; events[0].key = NOTHING; last--; swap(0, last); int downward = 0; while (downward < last) { int child1 = downward*2+1; int child2 = downward*2+2; int child = child1; if (child1 >= last) /* SECOND amendment */ { break; } else if (child2 >= last) { child = child1; } else /* Finding minimum between two children */ { } if (events[child2].key < events[child].key) { child = child2; } if (child >= last) { break; } else if (events[downward].key > events[child].key) { swap(downward, child); downward = child; } else { break; } } return res; }