Linked list implementation of Binary Min Heap (Having trouble with manipulation…)

后端 未结 5 634
囚心锁ツ
囚心锁ツ 2021-01-25 21:14

So i\'m trying to implement a binary min heap. I understand what the binary min heap entails in terms of it\'s structure and it\'s properties. However I\'m hitting a wall when I

5条回答
  •  情歌与酒
    2021-01-25 22:09

    Since you have to insert nodes at the bottom level, ie breadth wise , what if you maintain a record of all nodes inserted so far in a queue? When you insert a new node in the heap, find the latest position from the queue and insert the data there. Then heapify_up that node.

提交回复
热议问题