Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. how many times in your life have you implemented recursive methods

how many times in your life have you implemented recursive methods

Scheduled Pinned Locked Moved The Lounge
62 Posts 45 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Vasily Tserekh

    I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

    M Offline
    M Offline
    Michael Kingsford Gray
    wrote on last edited by
    #34

    At a guess/judgment, maybe over 300 distinct instances. (Not re-use of my library code) Or maybe more.

    1 Reply Last reply
    0
    • V Vasily Tserekh

      I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

      G Offline
      G Offline
      gr8gonzo
      wrote on last edited by
      #35

      Written a fair amount of recursive methods/functions. I do it a lot for file-processing code (things that have to recurse into subfolders and then into their subfolders, etc...), or almost any situation that uses a hierarchy.

      1 Reply Last reply
      0
      • V Vasily Tserekh

        I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

        H Offline
        H Offline
        Harrison Pratt
        wrote on last edited by
        #36

        Almost daily when writing Prolog.

        1 Reply Last reply
        0
        • L lewax00

          I've done it a few times...but who really needs to learn about them are the people who write the instructions on shampoo. I get stuck doing lather, rinse, repeat until I stack overflow because they forgot an end condition...

          C Offline
          C Offline
          Clodetta del Mar
          wrote on last edited by
          #37

          the end condition might be an empty bottle of shampoo, as the user you must specify the amount of shampoo you want (need) to use, so it´s possible to get out of the "not-so-endless-loop" in just one turn... ;)

          1 Reply Last reply
          0
          • V Vasily Tserekh

            I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

            C Offline
            C Offline
            cruest
            wrote on last edited by
            #38

            A LOT. Hell, a lot of the time I use recursion with static variables (searching a nodal structure for the highest value springs to mind). Pretty much any time you're working with nodal data, you probably should be using a recursive function, just sayin'. I can't tell you how many times I've been told that the depth of the data will not be more than X. Yeah right. Hope for X, implement for N I always say.

            1 Reply Last reply
            0
            • J jsc42

              Unfortunately, that is not recursion. It is an infinite iteration.

              F Offline
              F Offline
              Fabio Franco
              wrote on last edited by
              #39

              Nope, it's an infinite recursion. The link is a method call.

              To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

              E 1 Reply Last reply
              0
              • V Vasily Tserekh

                I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                F Offline
                F Offline
                Fabio Franco
                wrote on last edited by
                #40

                I think that happens to you for one of the reasons below: 1 - For the problems you need to solve on your tasks specifically, recursion is not a good solution. Although I find it difficult to never see business rules that can make good use of it. 2 - A stack makes more sense in the cases you find. 3 - You don't realize how recursion can be a great solution to your problems. To me it's just like math classes I had in college; I used to be really impressed with the vision my teacher had to solve some steps of the problem when I used a whole sheet of paper instead of 2 lines like he did.

                To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                1 Reply Last reply
                0
                • V Vasily Tserekh

                  I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                  B Offline
                  B Offline
                  BrainiacV
                  wrote on last edited by
                  #41

                  I've used it for drilling down through directories and tree structures, and some math functions use it. Once I used it to overcome a limitation of the DOS/370 Assembler, as opposed to the OS/370 Assembler. The DOS version would only allow you to assign 8 characters to a string. The OS version allowed up to 255 characters. I needed to parse some strings that I was using in a Macro. I noticed that if I called another Macro, I could pass 255 characters in the parameters. So I wrote a recursive Macro to peel apart the input string, add the new characters and then reassemble the characters of the symbol I wanted the Macro to create. One problem I found with recursion, is that once you understand it, you have a hard time going back to methods that do not use it. Back in my Apple II days, I needed to drill down through the new subdirectories that ProDOS (the quantum leap from DOS 3.3) now allowed you to create. Applesoft Basic did not support recursion. I stared at the problem for while because I remembered doing recursive like code before I learned recursion in PL/I. I was finally able to unwind my mind back to those days and got the program to do what I needed, but the whole time I was thinking how much easier the problem would have been if the language had supported it.

                  Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.

                  1 Reply Last reply
                  0
                  • V Vasily Tserekh

                    I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                    T Offline
                    T Offline
                    Thornik
                    wrote on last edited by
                    #42

                    I have to agree, recursion is the latest methodology I used in code. Once it was traversing directory tree and second is WPF visual tree. That's ALL! TWICE in my life :)))

                    1 Reply Last reply
                    0
                    • F Fabio Franco

                      Nope, it's an infinite recursion. The link is a method call.

                      To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                      E Offline
                      E Offline
                      englebart
                      wrote on last edited by
                      #43

                      And the back button on your browser is the "return" opcode

                      1 Reply Last reply
                      0
                      • A AspDotNetDev

                        I imagine some developers come across recursion more often than others. For example, I sometimes deal with recursion when writing code that traverses the file system, but I don't do that very often. Video game developers might do it when they handle BSP, closest path algorithms, collision detection, and so on. And just because you don't use it often does not mean it's not incredibly useful. Some problems might seem insurmountable without recursion. You might also seldom use trigonometry, but when you need it you really need it.

                        Thou mewling ill-breeding pignut!

                        E Offline
                        E Offline
                        englebart
                        wrote on last edited by
                        #44

                        For file system traversal, you only need to write the recursive code once. Then implement a visitor pattern.

                        class/interface DirectoryVisitor {
                        void enterDirectory(dirName, depthFromRoot) throws AbortTraversal;
                        void exitDirectory(dirName, depthFromRoot) throws AbortTraversal;
                        void visitFile(fileName, depthFromRoot) throws AbortTraverasl;
                        }

                        1 Reply Last reply
                        0
                        • V Vasily Tserekh

                          I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                          C Offline
                          C Offline
                          Conan Callen
                          wrote on last edited by
                          #45

                          What's the difference between recursive and redundant? ;P

                          1 Reply Last reply
                          0
                          • V Vasily Tserekh

                            I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                            G Offline
                            G Offline
                            geekware
                            wrote on last edited by
                            #46

                            Recursion is quite often the most elegant solution to many problems. I cannot encourage you enough to buy a copy of "The Little Schemer" by Daniel P. Friedman and Matthias Felleisen. It has but one aim, to teach you to think recursively. It will rock your world and make you a better code monkey. Plus you might develop a crush on Lisp/Scheme.

                            1 Reply Last reply
                            0
                            • M Mike Hankey

                              Quite often, recursion is very handy.

                              VS2010/Atmel Studio 6.0 ToDo Manager Extension
                              Version 3.0 now available. There is no place like 127.0.0.1

                              R Offline
                              R Offline
                              RafagaX
                              wrote on last edited by
                              #47

                              I've implemented recursive methods at most 10 times in my life, but half of these times, i had to replace them with iterative methods because of stack overflows or for consuming too much memory. :doh:

                              CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                              1 Reply Last reply
                              0
                              • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

                                Countless. I event made recursion is SQL... However today I use a better way to implement the idea of recursion - faster and lighter...

                                R Offline
                                R Offline
                                RafagaX
                                wrote on last edited by
                                #48

                                Kornfeld Eliyahu Peter wrote:

                                Countless. I event made recursion is SQL...

                                That's masochism. :-D

                                CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                                1 Reply Last reply
                                0
                                • V Vasily Tserekh

                                  I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                                  H Offline
                                  H Offline
                                  Harley L Pebley
                                  wrote on last edited by
                                  #49

                                  Frequently. A couple times in the last week alone.

                                  1 Reply Last reply
                                  0
                                  • V Vasily Tserekh

                                    I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                                    G Offline
                                    G Offline
                                    giuchici
                                    wrote on last edited by
                                    #50

                                    Like many others have said, recursion is not happening that often in most of programmers' lifes. However if you are designing a compiler, think of all the method calls: methods that call methods that call other methods and they have to return. Or functional programming languages rely heavily on recursion, using it where a procedural language would use iteration. You don't have to be a fancy compiler designer. I had to implement an electronic data interchange EDI for X12-211 Motor Carrier Bill of Lading. Good luck doing it without recursion. The point is that there are problems for which the recursive solution is 1000 time less consuming to implement than a traditional iterative way or any other way. Those are the moments you learn it for. And because it is not easy there's more satisfaction to be had when all the pieces come together and it works recursively. Cheers.

                                    giuchici

                                    1 Reply Last reply
                                    0
                                    • G gavindon

                                      Chris Losinger wrote:

                                      it helps to have done it before, because it can be a little tough to get your head around it sometimes.

                                      I agree, I still remember the smoke coming out of my classmates ears the section we were doing recursion in c++. course, come to think of it these were the same guys that responded with an answer of a "if" when asked what kind of loop they would use in "x" situation....... :doh: Thought my poor instructor was going to have a stroke on the spot. This was not in the beginning course either, it was in data structures. (3rd course in c++ for us, beginner, advanced, then data struct.).

                                      Common sense is not a gift it's a curse. Those of us who have it have to deal with those that don't.... Be careful which toes you step on today, they might be connected to the foot that kicks your butt tomorrow. You can't scare me, I have children.

                                      O Offline
                                      O Offline
                                      onemorechance
                                      wrote on last edited by
                                      #51

                                      Ah, yeah ... the old "if loop". I went to school with a few of those folks as well. Almost the exact same situation you described, but my instructor wasn't close to having a stroke ... he just made a miserable attempt at not laughing out loud.

                                      1 Reply Last reply
                                      0
                                      • G gavindon

                                        Chris Losinger wrote:

                                        it helps to have done it before, because it can be a little tough to get your head around it sometimes.

                                        I agree, I still remember the smoke coming out of my classmates ears the section we were doing recursion in c++. course, come to think of it these were the same guys that responded with an answer of a "if" when asked what kind of loop they would use in "x" situation....... :doh: Thought my poor instructor was going to have a stroke on the spot. This was not in the beginning course either, it was in data structures. (3rd course in c++ for us, beginner, advanced, then data struct.).

                                        Common sense is not a gift it's a curse. Those of us who have it have to deal with those that don't.... Be careful which toes you step on today, they might be connected to the foot that kicks your butt tomorrow. You can't scare me, I have children.

                                        L Offline
                                        L Offline
                                        Leng Vang
                                        wrote on last edited by
                                        #52

                                        Think recursive with C++ or any other high level languages is complex, try doing it in pure Lambda Expression. Still scratching my head.

                                        1 Reply Last reply
                                        0
                                        • V Vasily Tserekh

                                          I can count with the fingers of my hand the times I had to implement recursive methods in my life, so what was the fuzz all about when you are in school ant programming teachers tell you that that is the holy grail of programming!!! ps: i know that is important but most of recursive functions are implememnted and you only have to use them.

                                          J Offline
                                          J Offline
                                          jcmaida
                                          wrote on last edited by
                                          #53

                                          In compiler design, recursion is quite useful. It can get overly complicated though. For example: subroutine A and subroutine B are both recursive and call each other. You can see how complicated it can get tracing the execution path. Really not as bad it seems, but you better have your recursion hat on.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups