Click here to Skip to main content
15,888,816 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: help genetic algo Pin
Tim Craig15-Apr-07 18:08
Tim Craig15-Apr-07 18:08 
QuestionAnswer for this algorithm Pin
MoustafaS13-Apr-07 4:24
MoustafaS13-Apr-07 4:24 
AnswerRe: Answer for this algorithm Pin
CPallini13-Apr-07 4:37
mveCPallini13-Apr-07 4:37 
GeneralRe: Answer for this algorithm Pin
MoustafaS13-Apr-07 4:40
MoustafaS13-Apr-07 4:40 
AnswerRe: Answer for this algorithm [modified] Pin
Leslie Sanford13-Apr-07 4:46
Leslie Sanford13-Apr-07 4:46 
AnswerRe: Answer for this algorithm Pin
cp987613-Apr-07 4:47
cp987613-Apr-07 4:47 
GeneralRe: Answer for this algorithm Pin
MoustafaS13-Apr-07 4:51
MoustafaS13-Apr-07 4:51 
GeneralRe: Answer for this algorithm Pin
cp987613-Apr-07 4:59
cp987613-Apr-07 4:59 
In that case, start with an array of 51 numbers c[i] initialised to -1.
for (int i = 0 ; i < 51 ; i++)
   {
   if (a[i] < 51)
      {
      int n = 51 - a[i];
      if (c[n] >= 0)
        {
        // found one,  at a[i], a[c[n]]
        } 
      else
        {
        c[n] = i;
        }
      }
   }

Basically, for each element, store its location where its complement can find it







Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

GeneralRe: Answer for this algorithm Pin
MoustafaS13-Apr-07 5:02
MoustafaS13-Apr-07 5:02 
QuestionSkip List Indexing Pin
Leslie Sanford12-Apr-07 5:55
Leslie Sanford12-Apr-07 5:55 
AnswerRe: Skip List Indexing Pin
Luc Pattyn12-Apr-07 9:30
sitebuilderLuc Pattyn12-Apr-07 9:30 
GeneralRe: Skip List Indexing Pin
Leslie Sanford12-Apr-07 10:44
Leslie Sanford12-Apr-07 10:44 
QuestionThe Perfect Circle Pin
Bassam Abdul-Baki10-Apr-07 4:15
professionalBassam Abdul-Baki10-Apr-07 4:15 
AnswerRe: The Perfect Circle Pin
Paddy Boyd12-Apr-07 2:57
Paddy Boyd12-Apr-07 2:57 
QuestionLp,BP,HP filters design in C# Pin
Keleistein9-Apr-07 20:44
Keleistein9-Apr-07 20:44 
AnswerRe: Lp,BP,HP filters design in C# Pin
Roger Wright10-Apr-07 8:21
professionalRoger Wright10-Apr-07 8:21 
GeneralRe: Lp,BP,HP filters design in C# Pin
cp987611-Apr-07 1:46
cp987611-Apr-07 1:46 
Questionsome probability problem ? Pin
codeprojecter_8-Apr-07 23:56
codeprojecter_8-Apr-07 23:56 
AnswerRe: some probability problem ? Pin
cp98769-Apr-07 2:34
cp98769-Apr-07 2:34 
Questionconvert arrays of number to an integer Pin
Khodadad Pakdamans8-Apr-07 22:17
Khodadad Pakdamans8-Apr-07 22:17 
AnswerRe: convert arrays of number to an integer Pin
Luc Pattyn8-Apr-07 23:38
sitebuilderLuc Pattyn8-Apr-07 23:38 
GeneralRe: convert arrays of number to an integer Pin
cp98769-Apr-07 19:26
cp98769-Apr-07 19:26 
Questionan interesting program,please help Pin
Khodadad Pakdamans8-Apr-07 20:10
Khodadad Pakdamans8-Apr-07 20:10 
AnswerRe: an interesting program,please help Pin
cp98768-Apr-07 20:34
cp98768-Apr-07 20:34 
GeneralRe: an interesting program,please help Pin
Khodadad Pakdamans8-Apr-07 22:12
Khodadad Pakdamans8-Apr-07 22:12 

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.