Click here to Skip to main content
15,881,709 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionMultiple recursion & recursion? Pin
Ali_1008-Jun-09 23:54
Ali_1008-Jun-09 23:54 
AnswerRe: Multiple recursion & recursion? Pin
molesworth9-Jun-09 1:04
molesworth9-Jun-09 1:04 
GeneralRe: Multiple recursion & recursion? Pin
kanagarajm3-May-10 7:31
kanagarajm3-May-10 7:31 
AnswerRe: Multiple recursion & recursion? Pin
Colin Angus Mackay9-Jun-09 1:54
Colin Angus Mackay9-Jun-09 1:54 
AnswerRe: Multiple recursion & recursion? Pin
Luc Pattyn9-Jun-09 2:35
sitebuilderLuc Pattyn9-Jun-09 2:35 
AnswerRe: Multiple recursion & recursion? Pin
supercat99-Jun-09 7:02
supercat99-Jun-09 7:02 
AnswerRe: Multiple recursion & recursion? Pin
Baran M10-Jun-09 2:18
Baran M10-Jun-09 2:18 
AnswerRe: Multiple recursion & recursion? Pin
Pascal Ganaye10-Jun-09 2:28
Pascal Ganaye10-Jun-09 2:28 
There are a number of problems where a recursive algorithm is both simpler and faster than an loop.

For example QuickSort[^]
is one of the fastest sorting algorithm that have been found and it is using recursion.

http://en.wikipedia.org/wiki/Tower_of_Hanoi[^] is another example where recursion is really paying.

There are many more situation where recursion is needed.

It makes sense each time you can solve a problem by applying the same methods on its bits.

One of the typical example is a function that copy a folder somewhere else.

If you were to program it without recursion you would have to write:

function copyfolder(folder)
  for each file in folder
    copy file
  next
  for each subfolder in folder
    for each file in subfolder
      copy file
    next
    
    for each subsubfolder in subfolder
      for each file in subsubfolder
        copy file
      next
      ... what if there is some subsubsubfolders?
    next
  next
end function


Using a recursive algorithm you would have less code

function copyfolder(folder)
  for each file in folder
    copy file
  next
  for each subfolder in folder
    copyfolder(subfolder) ... this line is where the recursion happen
  next
end function


Signature
Seen in CodeProject forums :
Is it a sort of male dominance thing? You know, who can be the most witty? Who considers themselves the clown at the party?
Is it a follow the leader thing? One can't be seen not to have an elaborate signature, it's just no right, after all, all the other people have one.
(Is that long enough?)
GeneralTOols of testings Pin
Ali_1008-Jun-09 23:53
Ali_1008-Jun-09 23:53 
GeneralRe: TOols of testings Pin
Simon P Stevens9-Jun-09 0:46
Simon P Stevens9-Jun-09 0:46 
GeneralRe: TOols of testings Pin
Colin Angus Mackay9-Jun-09 1:57
Colin Angus Mackay9-Jun-09 1:57 
GeneralRe: TOols of testings Pin
Pete O'Hanlon9-Jun-09 2:19
mvePete O'Hanlon9-Jun-09 2:19 
GeneralRe: TOols of testings Pin
Eddy Vluggen9-Jun-09 7:37
professionalEddy Vluggen9-Jun-09 7:37 
GeneralMultiple inheritance Pin
Ali_1008-Jun-09 23:52
Ali_1008-Jun-09 23:52 
GeneralRe: Multiple inheritance Pin
Simon P Stevens9-Jun-09 0:39
Simon P Stevens9-Jun-09 0:39 
GeneralRe: Multiple inheritance Pin
supercat99-Jun-09 12:50
supercat99-Jun-09 12:50 
GeneralRe: Multiple inheritance Pin
Baran M9-Jun-09 1:38
Baran M9-Jun-09 1:38 
GeneralRe: Multiple inheritance Pin
Colin Angus Mackay9-Jun-09 1:47
Colin Angus Mackay9-Jun-09 1:47 
Questionremoting and client devices that switch network cards on the fly Pin
Martijn van Kleef8-Jun-09 22:08
Martijn van Kleef8-Jun-09 22:08 
QuestionGet message "keyset does not exist" when attempting to publish Pin
swampwiz7-Jun-09 13:28
swampwiz7-Jun-09 13:28 
AnswerRe: Get message "keyset does not exist" when attempting to publish Pin
Mark Salsbery8-Jun-09 12:36
Mark Salsbery8-Jun-09 12:36 
GeneralRe: Get message "keyset does not exist" when attempting to publish Pin
swampwiz8-Jun-09 14:18
swampwiz8-Jun-09 14:18 
GeneralRe: Get message "keyset does not exist" when attempting to publish Pin
Mark Salsbery8-Jun-09 14:25
Mark Salsbery8-Jun-09 14:25 
GeneralRe: Get message "keyset does not exist" when attempting to publish Pin
swampwiz10-Jun-09 8:51
swampwiz10-Jun-09 8:51 
GeneralRe: Get message "keyset does not exist" when attempting to publish Pin
Mark Salsbery10-Jun-09 8:55
Mark Salsbery10-Jun-09 8:55 

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.