Skip to content

Commit cb1701a

Browse files
committed
Fix max/min for ordered hash tables
1 parent 4dca3a9 commit cb1701a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Advanced.Algorithms/DataStructures/Dictionary/OrderedDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public KeyValuePair<K, V> NextLower(K key)
154154
/// </summary>
155155
public KeyValuePair<K, V> Max()
156156
{
157-
var max = binarySearchTree.Min();
157+
var max = binarySearchTree.Max();
158158
return max.Equals(default(OrderedKeyValuePair<K, V>)) ? default(KeyValuePair<K, V>)
159159
: max.ToKeyValuePair();
160160
}

src/Advanced.Algorithms/DataStructures/HashSet/OrderedHashSet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ public T NextLower(T value)
120120
/// </summary>
121121
public T Max()
122122
{
123-
return binarySearchTree.Min();
123+
return binarySearchTree.Max();
124124
}
125125

126126
/// <summary>
127127
/// Time complexity: O(log(n)).
128128
/// </summary>
129129
public T Min()
130130
{
131-
return binarySearchTree.Max();
131+
return binarySearchTree.Min();
132132
}
133133

134134
/// <summary>

0 commit comments

Comments
 (0)