Programming challenge: find top values in unsorted array

| | Comments (0) | TrackBacks (0)

Recently, I was given a programming problem for a pre-interview job screen.

Implementation
  • 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.
C# interface
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.

0 TrackBacks

Listed below are links to blogs that reference this entry: Programming challenge: find top values in unsorted array.

TrackBack URL for this entry: http://www.iwebthereforeiam.com/mt-tb.cgi/1623

Leave a comment

About this Entry

This page contains a single entry by Hugh Brown published on May 14, 2008 12:23 PM.

Grammatical pet peeve: the reason is because was the previous entry in this blog.

Weber 87886 Chimney Starter is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.