Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Heap Tree and Array (http://www.go4expert.com/forums/heap-tree-array-t28511/)

R1111 3Jun2012 20:07

Heap Tree and Array

If I have an array, and want to make a heap tree out of it using make heap and sort heap, how would I do it? I'm struggling because I didn't take any course in data structure.

I tried googling stuff and I got to the following:


#include <algorithm> // for std::make_heap, std::sort_heap
template <typename Iterator>
void heap_sort(Iterator begin, Iterator end)
    std::make_heap(begin, end);
    std::sort_heap(begin, end);

The thing is, I don't know what's the "Iterator" doing exactly and what's begin/end, how can I use arrays with the former piece of code?

Any help -in c++- will be appreciated

All times are GMT +5.5. The time now is 16:05.