-1

I want to use heaps to solve leetcode questions how can I import binary heap data structure without implementing it from scratch.

BinaryHeap<int> heap = new BinaryHeap<int>();

something like this.

  • Possible duplicate of [Fibonacci, Binary, or Binomial heap in c#?](https://stackoverflow.com/questions/428829/fibonacci-binary-or-binomial-heap-in-c) – Nico Schertler Oct 01 '19 at 22:12
  • 1
    There is no binary heap implementation supplied with the .NET Framework. If you search, you'll find multiple C# binary heap implementations that you can download. Pick one. – Jim Mischel Oct 01 '19 at 22:55
  • I'm preparing for interview, I can't implement the data structure in the code interview, is there any ready to use data structure that I can use instead of the heaps? – Saad Alyah Oct 02 '19 at 00:18
  • Questions seeking referrals to libraries, tutorials, examples, etc. are off-topic for Stack Overflow. In most cases, this will also exclude questions asking for referrals to specific API features. Even if not considered off-topic under that criteria, the fact is that your question is also too broad, given that you have provided zero details about how you expect to use this data structure, what research you've already done, and why the research you've already done hasn't provided you the answer you want. – Peter Duniho Oct 02 '19 at 01:34
  • Can you say in the interview: "Let's assume that there is a Priority Queue (or heap, if you definitely need a heap) implementation with the following interface:" And then provide the interface definition. (which should just be `Add`, `GetHighestPriorityItem`, and `Peek`). The interviewer should be fine with that. He might ask about time and space complexity, though. – Jim Mischel Oct 02 '19 at 16:53

1 Answers1

0

You can try SortedSet in C# which is to some extent same as BinaryMinHeap

Based on the problem you are trying to solve , you can check if SortedSet works for you.

SortedSet<int> heap = new SortedSet<int>();