Click here to Skip to main content
15,887,214 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: searching and order of aalgorithm Pin
Ian Shlasko29-Oct-09 11:33
Ian Shlasko29-Oct-09 11:33 
GeneralRe: searching and order of aalgorithm Pin
Member 419459329-Oct-09 12:51
Member 419459329-Oct-09 12:51 
GeneralRe: searching and order of aalgorithm Pin
Ian Shlasko29-Oct-09 13:01
Ian Shlasko29-Oct-09 13:01 
GeneralRe: searching and order of aalgorithm Pin
Member 419459329-Oct-09 13:13
Member 419459329-Oct-09 13:13 
GeneralRe: searching and order of aalgorithm Pin
Ian Shlasko29-Oct-09 13:31
Ian Shlasko29-Oct-09 13:31 
GeneralRe: searching and order of aalgorithm Pin
Alan Balkany29-Oct-09 16:29
Alan Balkany29-Oct-09 16:29 
GeneralRe: searching and order of aalgorithm Pin
Luc Pattyn29-Oct-09 13:17
sitebuilderLuc Pattyn29-Oct-09 13:17 
GeneralRe: searching and order of aalgorithm [modified] Pin
khomeyni29-Oct-09 21:34
khomeyni29-Oct-09 21:34 
in the name of god<br />
hello and thanks for your answers.<br />
it is the code i wrote in c++:<br />
<br />
int main(){<br />
  //here we declare variables<br />
  cin<<x;<br />
  //here first we sort the array with O(nlg(n))<br />
  mergeSort(Arbegin,Arend);//begin and end of array<br />
  //now we have a sorted array<br />
  int i=0;<br />
  //the order of below algorithm in worst case is O(n) so the order is :O(n)<br />
  while(i<j){<br />
    int sum=A[i]+A[j];<br />
    if(x < sum){<br />
      i++;<br />
    }<br />
    if(x < sum){<br />
      j--;<br />
    }<br />
    if(sum==x){<br />
      a=i;<br />
      b=j;<br />
      break;<br />
    }<br />
  }<br />
}<br />
valhamdolelah.




modified on Friday, October 30, 2009 8:20 AM

QuestionShortest path related Pin
Alivemau526-Oct-09 4:02
Alivemau526-Oct-09 4:02 
AnswerRe: Shortest path related Pin
Alan Balkany26-Oct-09 4:37
Alan Balkany26-Oct-09 4:37 
GeneralRe: Shortest path related Pin
Alivemau526-Oct-09 5:20
Alivemau526-Oct-09 5:20 
GeneralRe: Shortest path related Pin
Alan Balkany26-Oct-09 5:36
Alan Balkany26-Oct-09 5:36 
GeneralRe: Shortest path related Pin
Alivemau526-Oct-09 7:22
Alivemau526-Oct-09 7:22 
GeneralRe: Shortest path related Pin
Alan Balkany26-Oct-09 8:20
Alan Balkany26-Oct-09 8:20 
GeneralRe: Shortest path related Pin
Alan Balkany26-Oct-09 8:23
Alan Balkany26-Oct-09 8:23 
GeneralRe: Shortest path related Pin
Alivemau527-Oct-09 6:19
Alivemau527-Oct-09 6:19 
GeneralRe: Shortest path related Pin
ely_bob27-Oct-09 6:32
professionalely_bob27-Oct-09 6:32 
GeneralRe: Shortest path related Pin
Alan Balkany28-Oct-09 5:06
Alan Balkany28-Oct-09 5:06 
GeneralRe: Shortest path related Pin
Alivemau530-Oct-09 11:20
Alivemau530-Oct-09 11:20 
GeneralRe: Shortest path related Pin
Alan Balkany28-Oct-09 5:11
Alan Balkany28-Oct-09 5:11 
GeneralRe: Shortest path related Pin
Alivemau528-Oct-09 12:57
Alivemau528-Oct-09 12:57 
GeneralRe: Shortest path related Pin
Member 419459328-Oct-09 15:55
Member 419459328-Oct-09 15:55 
GeneralRe: Shortest path related Pin
Alivemau528-Oct-09 16:29
Alivemau528-Oct-09 16:29 
GeneralRe: Shortest path related Pin
Member 419459328-Oct-09 17:26
Member 419459328-Oct-09 17:26 
GeneralRe: Shortest path related Pin
Alivemau528-Oct-09 18:48
Alivemau528-Oct-09 18:48 

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.