Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void insert(E i) {
- if(heap.length == size)
- {
- doubleCapacity();
- }
- int currentindex =size;
- heap[currentindex] = i;
- size++;
- int parent = (int) Math.floor((currentindex-1)/2);
- while(heap[currentindex].compareTo(heap[parent]) <0)
- {
- E help = heap[parent];
- heap[parent]=heap[currentindex];
- heap[currentindex] = help;
- currentindex=parent;
- parent = (int) Math.floor((currentindex-1)/2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement