Archive for March, 2013

Interval Dictionary Library Published

I have published an alpha version of my new project: the Interval Dictionary. This collection is similar in function to System.Collections.Generic.Dictionary but rather than associating values to keys, a value is associated to an interval. This allows O(log n) retrieval of values based on a key that would fall within an interval.

Posted on March 23, 2013 at 1:49 pm by Steve Konves · Permalink · Leave a comment
In: Interval Dictionary, Projects

Nerd Sniped by Large Text Files

So I got nerd sniped pretty hard today with a software problem:

You have a text file such that:
• The file is too large to be loaded into memory
• Any record may be duplicated
• The top n most frequently occurring records in the file.

The solution for a small file is trivial. One simply needs to open a stream reader and load each line into a Dictionarysuch that if the key does not exist, add one for the current record add set the value to 1; if the key does exist, increment the value for the current record. At the end of the file, sort descending the dictionary by the values and then take the first n records. Bam balam. Easy-peasy.

Posted on March 4, 2013 at 11:20 pm by Steve Konves · Permalink · Leave a comment
In: Uncategorized