Show / Hide Table of Contents

Class MinMaxBinaryHeap<TKey, TValue>

Implements a MinMaxBinaryHeap and its main operations. Notice that a MaxMinHeapBinaryHeap can be implemented in a very similar way.

Inheritance
System.Object
BinaryHeapBase<TKey, TValue>
MinMaxBinaryHeap<TKey, TValue>
Implements
IBinaryHeap<TKey, TValue>
Inherited Members
BinaryHeapBase<TKey, TValue>.HeapArray
BinaryHeapBase<TKey, TValue>.BuildHeap_Iteratively(Int32)
BinaryHeapBase<TKey, TValue>.BuildHeap_Recursively(Int32)
BinaryHeapBase<TKey, TValue>.Insert(KeyValuePair<TKey, TValue>, Int32)
BinaryHeapBase<TKey, TValue>.TryRemoveRoot(KeyValuePair<TKey, TValue>, Int32)
BinaryHeapBase<TKey, TValue>.TryFindRoot(KeyValuePair<TKey, TValue>, Int32)
BinaryHeapBase<TKey, TValue>.BubbleDown_Recursively(Int32, Int32)
BinaryHeapBase<TKey, TValue>.BubbleDown_Iteratively(Int32, Int32)
BinaryHeapBase<TKey, TValue>.BubbleUp_Iteratively(Int32, Int32)
BinaryHeapBase<TKey, TValue>.GetLeftChildIndexInHeapArray(Int32)
BinaryHeapBase<TKey, TValue>.GetRightChildIndexInHeapArray(Int32)
BinaryHeapBase<TKey, TValue>.GetParentIndex(Int32)
BinaryHeapBase<TKey, TValue>.GetNodeLevel(Int32)
BinaryHeapBase<TKey, TValue>.TryFindIndexOfMinSmallerThanReference(List<KeyValuePair<TKey, TValue>>, List<Int32>, TKey, Int32)
BinaryHeapBase<TKey, TValue>.TryFindIndexOfMaxBiggerThanReference(List<KeyValuePair<TKey, TValue>>, Int32, List<Int32>, TKey, Int32)
BinaryHeapBase<TKey, TValue>.FindIndex(TKey)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: AlgorithmsAndDataStructures.DataStructures.BinaryHeaps
Assembly: AlgorithmsAndDataStructures.dll
Syntax
[DataStructure("MinMaxBinaryHeap")]
public class MinMaxBinaryHeap<TKey, TValue> : BinaryHeapBase<TKey, TValue>, IBinaryHeap<TKey, TValue> where TKey : IComparable<TKey>
Type Parameters
Name Description
TKey
TValue

Constructors

| Improve this Doc View Source

MinMaxBinaryHeap(List<KeyValuePair<TKey, TValue>>)

Constructor

Declaration
public MinMaxBinaryHeap(List<KeyValuePair<TKey, TValue>> array)
Parameters
Type Name Description
System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<TKey, TValue>> array

An array containing key-value pairs

Methods

| Improve this Doc View Source

BubbleDown_Iteratively(Int32, Int32)

Declaration
public override void BubbleDown_Iteratively(int rootIndex, int heapArrayLength)
Parameters
Type Name Description
System.Int32 rootIndex
System.Int32 heapArrayLength
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BubbleDown_Iteratively(System.Int32, System.Int32)
| Improve this Doc View Source

BubbleDown_Recursively(Int32, Int32)

Recursively bubbles down/trickles down the given rootIndex.

Declaration
public override void BubbleDown_Recursively(int rootIndex, int heapArrayLength)
Parameters
Type Name Description
System.Int32 rootIndex

The index of the node for which bubble down starts.

System.Int32 heapArrayLength

The length of the heap array.

Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BubbleDown_Recursively(System.Int32, System.Int32)
| Improve this Doc View Source

BubbleDownMax_Recursively(Int32, Int32)

Bubbles/trickles down the node at the given index, which is on a max/even level.

Declaration
public void BubbleDownMax_Recursively(int rootIndex, int heapArrayLength)
Parameters
Type Name Description
System.Int32 rootIndex

The index of the node at a max level, from which bubble down starts recursively.

System.Int32 heapArrayLength

The length of the heap array.

| Improve this Doc View Source

BubbleDownMin_Recursively(Int32, Int32)

Bubbles/trickles down the node at the given index, which is on a min/even level.

Declaration
public void BubbleDownMin_Recursively(int rootIndex, int heapArrayLength)
Parameters
Type Name Description
System.Int32 rootIndex

The index of a node at a min level, from which bubble down starts recursively.

System.Int32 heapArrayLength

The length of the heap array.

| Improve this Doc View Source

BubbleUp_Iteratively(Int32, Int32)

Declaration
public override void BubbleUp_Iteratively(int index, int heapArrayLength)
Parameters
Type Name Description
System.Int32 index
System.Int32 heapArrayLength
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BubbleUp_Iteratively(System.Int32, System.Int32)
| Improve this Doc View Source

BubbleUp_Recursively(Int32, Int32)

Bubbles up the node at the given index.

Declaration
public void BubbleUp_Recursively(int index, int heapArrayLength)
Parameters
Type Name Description
System.Int32 index

The index of a node in the heap array.

System.Int32 heapArrayLength

The length of the heap array.

| Improve this Doc View Source

BubbleUpMax_Recursively(Int32, Int32)

Bubbles up the node at the given index which is assumed to be on a max/odd level.

Declaration
public void BubbleUpMax_Recursively(int index, int heapArrayLength)
Parameters
Type Name Description
System.Int32 index

The index of a node in the heap array.

System.Int32 heapArrayLength

The length of the heap array.

| Improve this Doc View Source

BubbleUpMin_Recursively(Int32, Int32)

Bubbles up the node at the given index which is assumed to be on a min/even level.

Declaration
public void BubbleUpMin_Recursively(int index, int heapArrayLength)
Parameters
Type Name Description
System.Int32 index

The index of a node in the heap array.

System.Int32 heapArrayLength

The length of the heap array.

| Improve this Doc View Source

BuildHeap_Iteratively(Int32)

Declaration
public override void BuildHeap_Iteratively(int heapArrayLength)
Parameters
Type Name Description
System.Int32 heapArrayLength
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BuildHeap_Iteratively(System.Int32)
| Improve this Doc View Source

BuildHeap_Recursively(Int32)

Builds an in-place MinMax heap on the given array.

Declaration
public override void BuildHeap_Recursively(int heapArrayLength)
Parameters
Type Name Description
System.Int32 heapArrayLength

The length of the heap array.

Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.BuildHeap_Recursively(System.Int32)
| Improve this Doc View Source

Insert(KeyValuePair<TKey, TValue>, Int32)

Inserts a new value into the Min Heap.

Declaration
public override void Insert(KeyValuePair<TKey, TValue> keyValue, int heapArrayLength)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue> keyValue

The new key-value pair to be inserted in the tree.

System.Int32 heapArrayLength

The length of the heap array.

Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.Insert(System.Collections.Generic.KeyValuePair<TKey, TValue>, System.Int32)
| Improve this Doc View Source

IsMinLevel(Int32)

Given a node level in a MinMax heap, returns true if that node is on an even level, meaning on a Min level. and false otherwise/

Declaration
public bool IsMinLevel(int level)
Parameters
Type Name Description
System.Int32 level

The level of a node in a MinMax heap.

Returns
Type Description
System.Boolean

True in case of success, and false otherwise.

| Improve this Doc View Source

TryFindRoot(out KeyValuePair<TKey, TValue>, Int32)

This method is for finding the root of the heap, without removing it.

Declaration
public override bool TryFindRoot(out KeyValuePair<TKey, TValue> keyValue, int heapArrayLength)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue> keyValue

The key-value of the root.

System.Int32 heapArrayLength

The length of the heap array.

Returns
Type Description
System.Boolean

True in case of success, and false in case of failure.

Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.TryFindRoot(System.Collections.Generic.KeyValuePair<TKey, TValue>, System.Int32)
| Improve this Doc View Source

TryRemoveRoot(out KeyValuePair<TKey, TValue>, Int32)

Removes the min element from the heap.

Declaration
public override bool TryRemoveRoot(out KeyValuePair<TKey, TValue> keyValue, int heapArrayLength)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue> keyValue

If the operation is successful, contains the minimum element in the array.

System.Int32 heapArrayLength

The length of the heap array.

Returns
Type Description
System.Boolean
Overrides
AlgorithmsAndDataStructures.DataStructures.BinaryHeaps.API.BinaryHeapBase<TKey, TValue>.TryRemoveRoot(System.Collections.Generic.KeyValuePair<TKey, TValue>, System.Int32)

Implements

IBinaryHeap<TKey, TValue>
  • Improve this Doc
  • View Source
Back to top Generated by DocFX