Skip to content

Commit

Permalink
Fix max/min for ordered hash tables
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed Oct 26, 2018
1 parent 4dca3a9 commit cb1701a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public KeyValuePair<K, V> NextLower(K key)
/// </summary>
public KeyValuePair<K, V> Max()
{
var max = binarySearchTree.Min();
var max = binarySearchTree.Max();
return max.Equals(default(OrderedKeyValuePair<K, V>)) ? default(KeyValuePair<K, V>)
: max.ToKeyValuePair();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ public T NextLower(T value)
/// </summary>
public T Max()
{
return binarySearchTree.Min();
return binarySearchTree.Max();
}

/// <summary>
/// Time complexity: O(log(n)).
/// </summary>
public T Min()
{
return binarySearchTree.Max();
return binarySearchTree.Min();
}

/// <summary>
Expand Down

0 comments on commit cb1701a

Please sign in to comment.