CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: laserlight

Search: Search took 0.25 seconds.

  1. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    It is a simpler way of writing &a[size].


    It is wrong. Once you do sort_heap, the range is no longer a heap, so you cannot subsequently call push_heap with it. Furthermore, the first argument to...
  2. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    Something like this:

    #include <algorithm>

    int main()
    {
    const int capacity = 11;
    int a[capacity] = {1, 2, 3, 4, 5, 6, 7};
    int size = 7;
    std::make_heap(a, a + size);
  3. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    No, that is not what it means. Rather, it states that the element at that position in the range (i.e., the range of the array, vector, etc) is inserted into the heap that consists of the elements of...
  4. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    Simple: you pass a pointer to one past the newest array element in use as the second argument to push_heap.

    Or, let me ask you: what do you understand by the statement that push_heap "inserts the...
  5. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    There is no equivalent. You cannot increase the size of an array. As I mentioned, you could create an array as big as you will ever need then incrementally use it, but unless you have special and...
  6. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    You cannot add values to your array because your array's size is fixed at compile time. What you can do is create an array as large as you will ever need and then just use part of it incrementally,...
  7. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    What is the bigger picture of what you are trying to do?

    Do you understand what pop_heap and push_heap do? If not, read stuff like cppreference.com's entries on pop_heap and push_heap.
  8. Replies
    16
    Views
    19,258

    Re: Array to Heap Tree

    You would only need to use make_heap, methinks. The begin/end iterators of an array would be a pointer to the first element of the array and a pointer to one past the last element of the array,...
Results 1 to 8 of 8





Click Here to Expand Forum to Full Width

Featured