Task: Demonstrate Lazy Evaluation Optimization for Minimum via Sort in Haskell
Task: Demonstrate Lazy Evaluation Optimization for Minimum via Sort in Haskell: a task in Terminal-Lego-15k (Harbor dataset). In Haskell, due to lazy evaluation, the composition minimum = head . sort runs in O(n) time rather than O(n log n), even when using a comparison-based sort like merge sort…
The task
In Haskell, due to lazy evaluation, the composition `minimum = head . sort` runs in O(n) time rather than O(n log n), even when using a comparison-based sort like merge sort. This is because lazy evaluation ensures that `sort` only does enough work to produce the first element of the sorted list (the minimum), and…
Part of PrimeIntellect/Terminal-Lego-15k.