Class DaryMaxHeap<T>
A D-ary max heap implementation.
Namespace: Advanced.Algorithms.DataStructures
Assembly: Advanced.Algorithms.dll
Syntax
public class DaryMaxHeap<T> : IEnumerable<T> where T : IComparable
Type Parameters
Name | Description |
---|---|
T |
Constructors
DaryMaxHeap(Int32, IEnumerable<T>)
Time complexity: O(n) when initial is provided otherwise O(1).
Declaration
public DaryMaxHeap(int k, IEnumerable<T> initial = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | k | The number of children per heap node. |
IEnumerable<T> | initial | The initial items if any. |
Fields
Count
Declaration
public int Count
Field Value
Type | Description |
---|---|
Int32 |
Methods
ExtractMax()
Time complexity: O(log(n) base K).
Declaration
public T ExtractMax()
Returns
Type | Description |
---|---|
T |
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> |
Insert(T)
Time complexity: O(log(n) base K).
Declaration
public void Insert(T newItem)
Parameters
Type | Name | Description |
---|---|---|
T | newItem |
PeekMax()
Time complexity: O(1).
Declaration
public T PeekMax()
Returns
Type | Description |
---|---|
T |