Search code examples
algorithmbinary-treebinary-heapbinomial-heap

insert same values into binomial heap


I have to insert some values into binomial heap. For example 25, 26, 24, 60, 65, 62. It will look like follows: enter image description here

But then I have to insert 25, 68, 65 to the same heap. Should I insert 25 again or just skip it as it is already present in the heap?


Solution

  • It is up to your implementation and specific requirements. Do you need duplicate elements? A binomial heap can support inserting the same value multiple times and will perform just as good(if you implement it correctly), but this does not mean that it should in your case.