A special HEAP with binary search in the right path


  • 0
    M

    Accoding to observation, we can find that

    1. the Tree is an in-complete heap
    2. every new number (x) in, just go through the right path of the HEAP, and find the first node whose value is less than (x)
    3. insert node(x) at the found place, and let the previous node to be x->left
    4. repeat step 2 and 3 until all numbers inserted
    5. the search in step 2 can be improved by binary search

    The code will be posted here later.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.