Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: How would you store this data (interview question) Pin
SledgeHammer013-Feb-12 7:06
SledgeHammer013-Feb-12 7:06 
GeneralRe: How would you store this data (interview question) Pin
BillWoodruff3-Feb-12 7:36
professionalBillWoodruff3-Feb-12 7:36 
GeneralRe: How would you store this data (interview question) Pin
SledgeHammer013-Feb-12 8:19
SledgeHammer013-Feb-12 8:19 
GeneralRe: How would you store this data (interview question) Pin
BillWoodruff3-Feb-12 13:33
professionalBillWoodruff3-Feb-12 13:33 
GeneralRe: How would you store this data (interview question) Pin
SledgeHammer013-Feb-12 13:53
SledgeHammer013-Feb-12 13:53 
Questionevents Pin
michaelgr12-Feb-12 8:08
michaelgr12-Feb-12 8:08 
AnswerRe: events Pin
SledgeHammer012-Feb-12 8:19
SledgeHammer012-Feb-12 8:19 
Generallots of license plates Pin
Luc Pattyn2-Feb-12 8:27
sitebuilderLuc Pattyn2-Feb-12 8:27 
AFAICT your suggestion has two major drawbacks, memory-wise:
1. it repeats the leading symbols over and over;
2. for each new chunk of license plates it costs a pointer.

I'd consider an N-tier approach; for N=2 that would be some data structure for the rightmost say 3 symbols, and then a second layer of structure to hold all of those, representing the remaining symbols.

The first one could be a run-length as you described, or a linked list, or switch from one to the other scheme depending on the population.
The second one could be a full array, or maybe a dictionary.

Maybe a 3-tier approach would be optimal: an array for 2 symbols (36^2 elements), pointing to an array for 2 symbols, pointing to an array for 2 symbols, holding a 36-bit bitmask for the last symbol. (Yes it would work better if there were only 32 symbols in the alphabet used).

Note: the "pointers" above don't have to be real pointers, they could be indexes into a huge array, requiring say 4B each rather than 8B.

And the simplest approach that might be good enough would be a Dictionary<string,long> where the key holds the first N-1 symbols, and the value is a bitmask covering the last symbol.

Smile | :)

PS: this is what I was going to reply to your vanishing question in Algos
Luc Pattyn [My Articles] Nil Volentibus Arduum

Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.

GeneralRe: lots of license plates Pin
SledgeHammer012-Feb-12 8:30
SledgeHammer012-Feb-12 8:30 
AnswerRe: lots of license plates Pin
Luc Pattyn2-Feb-12 8:31
sitebuilderLuc Pattyn2-Feb-12 8:31 
GeneralRe: lots of license plates Pin
BillWoodruff3-Feb-12 5:02
professionalBillWoodruff3-Feb-12 5:02 
AnswerRe: events Pin
Luc Pattyn2-Feb-12 8:22
sitebuilderLuc Pattyn2-Feb-12 8:22 
AnswerRe: events Pin
Bernhard Hiller2-Feb-12 21:29
Bernhard Hiller2-Feb-12 21:29 
GeneralRe: events Pin
michaelgr13-Feb-12 23:18
michaelgr13-Feb-12 23:18 
GeneralRe: events Pin
BobJanova4-Feb-12 1:39
BobJanova4-Feb-12 1:39 
GeneralRe: events Pin
michaelgr14-Feb-12 2:32
michaelgr14-Feb-12 2:32 
QuestionBlind Watermarking With DWT Pin
fidelis jamboreoog2-Feb-12 5:58
fidelis jamboreoog2-Feb-12 5:58 
AnswerRe: Blind Watermarking With DWT Pin
Mycroft Holmes2-Feb-12 14:02
professionalMycroft Holmes2-Feb-12 14:02 
QuestionA method to refresh MappedNetworkDrives in code? Pin
mlyons2-Feb-12 5:52
mlyons2-Feb-12 5:52 
AnswerRe: A method to refresh MappedNetworkDrives in code? Pin
SledgeHammer012-Feb-12 7:15
SledgeHammer012-Feb-12 7:15 
AnswerRe: A method to refresh MappedNetworkDrives in code? Pin
Mycroft Holmes2-Feb-12 14:05
professionalMycroft Holmes2-Feb-12 14:05 
GeneralRe: A method to refresh MappedNetworkDrives in code? Pin
mlyons3-Feb-12 2:59
mlyons3-Feb-12 2:59 
QuestionPInvoke stack overflow Pin
openLG2-Feb-12 2:47
openLG2-Feb-12 2:47 
AnswerRe: PInvoke stack overflow Pin
OriginalGriff2-Feb-12 2:59
mveOriginalGriff2-Feb-12 2:59 
GeneralRe: PInvoke stack overflow Pin
openLG2-Feb-12 3:09
openLG2-Feb-12 3:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.