Click here to Skip to main content
15,903,175 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: calculus... Pin
Anton Afanasyev10-Oct-06 22:11
Anton Afanasyev10-Oct-06 22:11 
GeneralRe: calculus... Pin
Ryan Binns10-Oct-06 22:20
Ryan Binns10-Oct-06 22:20 
GeneralRe: calculus... Pin
Vikram A Punathambekar10-Oct-06 23:00
Vikram A Punathambekar10-Oct-06 23:00 
GeneralRe: calculus... Pin
Ryan Binns10-Oct-06 23:04
Ryan Binns10-Oct-06 23:04 
GeneralRe: calculus... [modified] Pin
Stephen Hewitt12-Oct-06 13:59
Stephen Hewitt12-Oct-06 13:59 
QuestionSearch Algorithm Pin
MoustafaS10-Oct-06 10:28
MoustafaS10-Oct-06 10:28 
AnswerRe: Search Algorithm [modified] Pin
Kastellanos Nikos10-Oct-06 23:42
Kastellanos Nikos10-Oct-06 23:42 
AnswerRe: Search Algorithm Pin
Kastellanos Nikos11-Oct-06 0:02
Kastellanos Nikos11-Oct-06 0:02 
That's what pop into my mind:

<br />
sumx(A[],x)<br />
{<br />
  Array S[x/2];<br />
  for(i=0,i<S.lenght;i++) S[i]=0;  //set all elements to 0 <br />
  for(i=0,i<A.lenght;i++)<br />
  { <br />
    a=A[i];<br />
    if(a<0 || a>x/2) continue;<br />
    if(a<x/2) S[a]   |= 1;<br />
    if(a>x/2) S[x-a] |= 2;<br />
  }<br />
  return S;<br />
}<br />


You get an array S.
For a number k<(x/2) you have:
if S[k] is 0 then neither number k, nor (x-k) is in the input array.
if S[k] is 1 then only number k was in the input array.
if S[k] is 2 then only number (x-k) was in the input array.
if S[k] is 3 then k and (x-k) was in the input array. The sum of those two is k+(x-k)=k+x-k=x. bingo! Rose | [Rose]
For a number j>(x/2) you have k=(x-j) and continue as above.

The array S can be more comlex, like storing the index of two number in the input array A, if you like. Dealling with negative numbers as well might need a more complex aproach.
GeneralRe: Search Algorithm Pin
Anand Vivek Srivastava11-Oct-06 4:31
Anand Vivek Srivastava11-Oct-06 4:31 
Questiondeterminant of a matrix Pin
cagdasanilan4-Oct-06 4:15
cagdasanilan4-Oct-06 4:15 
AnswerRe: determinant of a matrix Pin
User 66588-Oct-06 13:28
User 66588-Oct-06 13:28 
AnswerRe: determinant of a matrix Pin
cagdasanilan8-Oct-06 22:58
cagdasanilan8-Oct-06 22:58 
AnswerRe: determinant of a matrix Pin
ejuanpp18-Oct-06 11:48
ejuanpp18-Oct-06 11:48 
GeneralRe: determinant of a matrix Pin
cagdasanilan21-Oct-06 8:07
cagdasanilan21-Oct-06 8:07 
GeneralRe: determinant of a matrix Pin
ejuanpp22-Oct-06 22:47
ejuanpp22-Oct-06 22:47 
GeneralRe: determinant of a matrix Pin
cagdasanilan26-Oct-06 4:06
cagdasanilan26-Oct-06 4:06 
QuestionPort To Application Mapping (aka PAM)... Pin
Shy Agam29-Sep-06 11:06
Shy Agam29-Sep-06 11:06 
Questionimage convolution Pin
Prinz Ryoiji27-Sep-06 22:02
Prinz Ryoiji27-Sep-06 22:02 
AnswerRe: image convolution Pin
Dominik Reichl29-Sep-06 7:43
Dominik Reichl29-Sep-06 7:43 
AnswerRe: image convolution [modified] Pin
ejuanpp2-Oct-06 1:46
ejuanpp2-Oct-06 1:46 
Questionlooking for a source code... Pin
good_buttercup27-Sep-06 19:04
good_buttercup27-Sep-06 19:04 
AnswerRe: looking for a source code... Pin
User 58385227-Sep-06 20:45
User 58385227-Sep-06 20:45 
AnswerRe: looking for a source code... Pin
good_buttercup27-Sep-06 21:22
good_buttercup27-Sep-06 21:22 
Questionbayesian belief network algorithm Pin
good_buttercup27-Sep-06 18:29
good_buttercup27-Sep-06 18:29 
QuestionEnglish Word Tense Pin
chinajuanbob22-Sep-06 23:15
chinajuanbob22-Sep-06 23:15 

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.