Click here to Skip to main content
15,894,180 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Finding several extra/missing numbers Pin
supercat919-Dec-08 7:00
supercat919-Dec-08 7:00 
GeneralRe: Finding several extra/missing numbers Pin
Luc Pattyn19-Dec-08 7:25
sitebuilderLuc Pattyn19-Dec-08 7:25 
GeneralRe: Finding several extra/missing numbers Pin
supercat919-Dec-08 8:56
supercat919-Dec-08 8:56 
GeneralRe: Finding several extra/missing numbers Pin
Luc Pattyn19-Dec-08 9:36
sitebuilderLuc Pattyn19-Dec-08 9:36 
GeneralRe: Finding several extra/missing numbers Pin
supercat921-Dec-08 12:28
supercat921-Dec-08 12:28 
GeneralRe: Finding an extra/missing number Pin
cp987619-Dec-08 11:46
cp987619-Dec-08 11:46 
GeneralRe: Finding an extra/missing number Pin
Luc Pattyn19-Dec-08 12:48
sitebuilderLuc Pattyn19-Dec-08 12:48 
GeneralRe: Finding an extra/missing number Pin
supercat920-Dec-08 15:57
supercat920-Dec-08 15:57 
Just adding together numbers is apt to cause some confusion as bits carry from one place to the next. For n=3 or n=4 I would think it would be best to do something like:
/* For each number x read from the input */
for (i=0; i<16; i++)
{
  if (x & (2 << i))  /* Yes I know this isn't optimized */
  {
    count1[i] ^= (count0[i] & x);
    count0[i] ^= x;
  }
}

That will indicate whether a bit is set in 0, 1, 2, 3 (mod 4) of the missing numbers that have a particular bit set. The case where a bit is missing in all four numbers can be resolved by noting that there must be some other bit which does not appear in all four numbers, so the count0/1[] values for that bit will show that it's missing in at least some numbers.
GeneralRe: Finding an extra/missing number [modified] Pin
cp987621-Dec-08 13:58
cp987621-Dec-08 13:58 
GeneralRe: Finding an extra/missing number Pin
supercat922-Dec-08 9:58
supercat922-Dec-08 9:58 
GeneralRe: Finding an extra/missing number Pin
Mark Churchill22-Dec-08 18:55
Mark Churchill22-Dec-08 18:55 
GeneralRe: Finding an extra/missing number Pin
supercat923-Dec-08 6:55
supercat923-Dec-08 6:55 
GeneralRe: Finding an extra/missing number Pin
stevepqr8-Jan-09 5:59
stevepqr8-Jan-09 5:59 
AnswerRe: Question from my Phone Interview Pin
C Change25-Jan-09 0:55
C Change25-Jan-09 0:55 
QuestionWhat is Combinatorial Optimization? Pin
alexdow13-Dec-08 9:39
alexdow13-Dec-08 9:39 
AnswerRe: What is Combinatorial Optimization? Pin
Alan Balkany15-Dec-08 3:57
Alan Balkany15-Dec-08 3:57 
QuestionSome kind of LCS Pin
aggressorus9-Dec-08 7:22
aggressorus9-Dec-08 7:22 
Questionhelp me About Big O Pin
bosszy7-Dec-08 2:00
bosszy7-Dec-08 2:00 
GeneralRe: help me About Big O Pin
Luc Pattyn7-Dec-08 6:32
sitebuilderLuc Pattyn7-Dec-08 6:32 
AnswerRe: help me About Big O Pin
Paul Conrad9-Dec-08 11:37
professionalPaul Conrad9-Dec-08 11:37 
GeneralRe: help me About Big O Pin
Luc Pattyn9-Dec-08 13:13
sitebuilderLuc Pattyn9-Dec-08 13:13 
GeneralRe: help me About Big O Pin
Paul Conrad9-Dec-08 13:15
professionalPaul Conrad9-Dec-08 13:15 
AnswerRe: help me About Big O Pin
73Zeppelin10-Dec-08 18:51
73Zeppelin10-Dec-08 18:51 
AnswerRe: help me About Big O Pin
J. Andrew Smith6-Mar-09 3:16
J. Andrew Smith6-Mar-09 3:16 
QuestionCholeski's Algorithm Pin
BobInNJ6-Dec-08 6:06
BobInNJ6-Dec-08 6:06 

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.