Click here to Skip to main content
15,914,010 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionStoring more values in single BYTE. Pin
Sameerkumar Namdeo5-Nov-07 22:29
Sameerkumar Namdeo5-Nov-07 22:29 
JokeRe: Storing more values in single BYTE. Pin
CPallini6-Nov-07 2:08
mveCPallini6-Nov-07 2:08 
JokeRe: Storing more values in single BYTE. Pin
El Corazon6-Nov-07 3:29
El Corazon6-Nov-07 3:29 
GeneralRe: Storing more values in single BYTE. Pin
CPallini6-Nov-07 3:33
mveCPallini6-Nov-07 3:33 
JokeRe: Storing more values in single BYTE. Pin
El Corazon6-Nov-07 4:01
El Corazon6-Nov-07 4:01 
AnswerRe: Storing more values in single BYTE. Pin
Dan Neely6-Nov-07 2:14
Dan Neely6-Nov-07 2:14 
AnswerRe: Storing more values in single BYTE. Pin
Sameerkumar Namdeo6-Nov-07 19:33
Sameerkumar Namdeo6-Nov-07 19:33 
GeneralRe: Storing more values in single BYTE. Pin
Dan Neely7-Nov-07 2:19
Dan Neely7-Nov-07 2:19 
You cannot store more than 256 unique values in individual cells of a Byte array. You could reduce your memory footprint in two ways.

The first would be to compress the array in memory. The cost of that would be the loss of easy random access. Instead of O(C) performance to access an arbitrary value you'd have O(N) performance, like a linked list. IIRC with most modern compression algos modifying a value will require recompressing the array from the insert point forward, making an insert even more expensive.

The second would be to use bit packing, to simulate a 9bit int. This would remain O(C) performance, but the constant value would be much higher.

You'd probably need to implement both these approaches and try multiple compression algos for the first (compressed size vs speed to partially decompress to get an arbitrary value) and do performance testing to see if these are actually faster than using an extra 1 meg of memory (using a 16bit int).

Unless you're working on an embedded system with very tight memory constraints however I'm doubtful that either will actually be faster if you're doing any nontrivial examination/processing of the data.

--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.

GeneralRe: Storing more values in single BYTE. Pin
Sameerkumar Namdeo7-Nov-07 17:04
Sameerkumar Namdeo7-Nov-07 17:04 
AnswerRe: Storing more values in single BYTE. Pin
sgorozco28-Nov-07 19:52
sgorozco28-Nov-07 19:52 
QuestionRelative Speed of Trigonometry functions Pin
MikeMarq4-Nov-07 6:46
MikeMarq4-Nov-07 6:46 
AnswerRe: Relative Speed of Trigonometry functions Pin
Luc Pattyn4-Nov-07 6:59
sitebuilderLuc Pattyn4-Nov-07 6:59 
AnswerRe: Relative Speed of Trigonometry functions Pin
Paul Conrad4-Nov-07 7:31
professionalPaul Conrad4-Nov-07 7:31 
AnswerRe: Relative Speed of Trigonometry functions Pin
cmk4-Nov-07 10:22
cmk4-Nov-07 10:22 
GeneralRe: Relative Speed of Trigonometry functions Pin
Paul Conrad4-Nov-07 10:53
professionalPaul Conrad4-Nov-07 10:53 
GeneralRe: Relative Speed of Trigonometry functions Pin
Dan Neely5-Nov-07 2:20
Dan Neely5-Nov-07 2:20 
GeneralRe: Relative Speed of Trigonometry functions Pin
Paul Conrad5-Nov-07 12:05
professionalPaul Conrad5-Nov-07 12:05 
GeneralRe: Relative Speed of Trigonometry functions Pin
Dan Neely5-Nov-07 12:46
Dan Neely5-Nov-07 12:46 
GeneralRe: Relative Speed of Trigonometry functions Pin
Paul Conrad5-Nov-07 14:05
professionalPaul Conrad5-Nov-07 14:05 
GeneralRe: Relative Speed of Trigonometry functions Pin
Robodroid17-Jan-08 10:15
Robodroid17-Jan-08 10:15 
GeneralRe: Relative Speed of Trigonometry functions Pin
MikeMarq4-Nov-07 19:54
MikeMarq4-Nov-07 19:54 
GeneralRe: Relative Speed of Trigonometry functions Pin
cp98764-Nov-07 22:27
cp98764-Nov-07 22:27 
AnswerRe: Relative Speed of Trigonometry functions Pin
Luc Pattyn5-Nov-07 2:36
sitebuilderLuc Pattyn5-Nov-07 2:36 
AnswerRe: Relative Speed of Trigonometry functions Pin
Alan Balkany29-Nov-07 5:02
Alan Balkany29-Nov-07 5:02 
AnswerRe: Relative Speed of Trigonometry functions Pin
serge_bal19-Dec-07 5:38
serge_bal19-Dec-07 5:38 

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.