I was once given the following interview question:
Design and implement a method to select the largest
m
values from a very large list ofn
numbers.
I liked this question because solving it (the way we'll be doing) touches on a good cross section of software design in Scala:
- complexity ("Big O") analysis
- polymorphism (subclassing, traits, and bounds)
- testing!
- ...and a few Scala-flavored ideas:
- companion objects
- implicit values
In this post we'll examine the problem, calling out a few factors that make this question interesting, and propose a design for our solution.
In upcoming posts, we'll follow the design through implementation, functional testing, and add a few bells and whistles. ...more