Recently, I was given a programming problem for a pre-interview job screen.
Implementation
C# interface
- Create a class which implements either the C# or Java interface
- Implement the two methods defined in the interface. FindMaxValue should return the single highest integer. FindTopNValues should return a list of the highest 'n' values in the source list
- Any assumptions or design choices made during the implementation should be documented.
namespace Test { public interface IFindTopValues { int FindMaxValue(int[] values); int[] FindTopNValue(int[] values, int count); }Test cases
- Describe the test cases which you would implement for this class.
Here's the solution I produced. It uses a C# generic PriorityQueue class. Have a look -- it's useful, reusable code.
Update (2008-05-15): I noticed that Julian Bucknall had a change to his priority queue that ordered entries by priority and time of entry. I decided to update my code to provide the same ability.

Leave a comment