Heap Tree and Array

Discussion in 'C' started by R1111, Jun 3, 2012.

  1. R1111

    R1111 New Member

    Joined:
    Jun 3, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    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:

    Code:
    #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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice