Can you help me with my programing homework in c++ for Heaps. More info in comments. Thanks

Posted by Erao_@reddit | learnprogramming | View on Reddit | 6 comments

I am stuck on how to make it that it doesent wait for 10000 elements and that it will sort even 2 for example also i still realy doesent understand heapsort and i heard that i could use swap so i would like to know what that is. thanks any help is realy appreciated.

Here are the original instructions: 

Heap Sort (HeapSort) 

→ total time complexity O(N.log N) even in the worst case 

Sorts in-place (doesn't need an extra data structure of size N): 

Your Task: 

You have basic knowledge of the heap data structure and the HeapSort algorithm. Your task is to implement a sort method for an array of the record structure defined below. The sorting algorithm must work in-place. You don't need to worry about time complexity. 

Your submission must include: 

  1. A program with a sort method that takes an input array of record elements and sorts them from oldest to newest (by addTime). Elements are read from standard input. Assume a maximum array size of 10 000. The program should also print the sorted array. 

Structure record: 

Members: 

  1. string id 
  2. unsigned int addTime (representing a unix timestamp) 
  3. char category 

Here is the input: 

66a82653-e164-4c67-89a7-1a266b82b2f0 1209807225 E 

175c09e6-7776-4a45-a7f1-5e4a27282e38 724367075 D