Skip to content

JetStream96/MinMaxHeap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MinMaxHeap

C# implementation of min-heap and max-heap.

Classes

  • MinHeap<T>
  • MinHeap<TKey, TValue>
  • MinHeap<TKey, TValue, TDictionary>
  • MaxHeap<T>
  • MaxHeap<TKey, TValue>
  • MaxHeap<TKey, TValue, TDictionary>

Usage

    var heap = new MinHeap<int>();
    heap.Add(3);
    heap.Add(9);
    
    int x = heap.ExtractMin();  // Returns 3.
    int num = heap.Count;	    // Returns 1.
    int y = heap.ExtractMin();  // Returns 9.
    var heap = new MinHeap<string, int>();

    heap.Add("item1", 3);
    heap.Add("item2", 4);
    heap.Add("item3", 5);
    heap.ChangeValue("item2", 1);   // Now value of "item2" is 1.
    int x = heap.ExtractMin();      // Returns 1.

Tests

All tests can be run with NUnit 3.

License

Public domain.

About

C# implementation of min-heap and max-heap.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages