0

That probably was not the best description for it. My question is using a heap of lists how would you find the shortest out of the multiple heaps and then add the next element to it? Is this easy? I am not looking for the code for it. Really looking for an explanation of if/how it could be done. I just started learning about heaps so any help would be really appreciated!

programmer 20
  • 59
  • 1
  • 6
  • This is very unclear. Are you trying to find the shortest list in a heap, or do you have multiple heaps that contain lists? – jchamp Apr 17 '16 at 00:43
  • Yes, sorry and shortest list in a heap – programmer 20 Apr 17 '16 at 21:45
  • 1
    Try creating a min heap and use the length of your lists to order the heap. That way, your shortest list will always be at the root of the heap. – jchamp Apr 18 '16 at 23:58
  • And after you add an item to the list, you have to re-sift the root element, because it might have become longer than the next-longest. – Jim Mischel Aug 08 '16 at 21:28

0 Answers0