- Joined
- Jul 10, 2007
- Messages
- 6,306
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Nestharus said:HINDYhat, you still have to index the last element into the empty position
Or perhaps I misunderstood. This is a trivial operation anyway.HINDYhat said:... and then move the last node into that empty position
EDIT: Sorry, I was wrong. Let me think about this.Nestharus said:Then you'd have to bubble the last element up.
well, the bubble down is rather standard and guarantees O(log n) whereas the other method could possibly be 2*O(log n)-1.
And HINDYhat, thank you very much for commenting on algorithm : ).
If you ever want to review code of mine and find it hard to read, I can explain the algorithm I used ; P. After all, the algorithm is more important than the code : D.
exitwhen (0 == parent or compare(parent.node.value, value))
/* Interface:
* private static method compare takes thistype value1, thistype value2 returns boolean
* - < for minimum heap
* - > for maximum heap
*/
Is it me, or does it say that the compare method does not exist when implementing this allocator?
JASS:exitwhen (0 == parent or compare(parent.node.value, value))
exitwhen (0 == parent or parent.node.value > (or < o.O) value)
static method compare takes thistype value1, thistype value2 returns boolean
return integer(value1) < integer(value2)
endmethod
static method compare takes thistype value1, thistype value2 returns boolean
return integer(value1) > integer(value2)
endmethod
interface myInterface
private static method compare takes thistype value1, thistype value2 returns boolean
endinterface
struct myStruct extends myInterface
static method compare takes thistype value1, thistype value2 returns boolean
return integer(value1) > integer(value2)
endmethod
endstruct
no..
look up interface in programming >.<
edit
http://msdn.microsoft.com/en-us/library/87d83y5b(v=vs.80).aspx
struct Heap extends array
private static method compare takes integer value1, integer value2 returns boolean
return value1 >= value2
endmethod
implement BinaryHeap
endstruct
JASS:struct Heap extends array private static method compare takes integer value1, integer value2 returns boolean return value1 >= value2 endmethod implement BinaryHeap endstruct
