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. General Programming
  3. C#
  4. Any one help me about the Recursion Concept Diagramatically.

Any one help me about the Recursion Concept Diagramatically.

Scheduled Pinned Locked Moved C#
helpquestion
10 Posts 9 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.
  • S Offline
    S Offline
    sgunasekhar
    wrote on last edited by
    #1

    I was just confusing How it works ?

    OriginalGriffO K U A A 8 Replies Last reply
    0
    • S sgunasekhar

      I was just confusing How it works ?

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Have a look at Wiki: http://en.wikipedia.org/wiki/Recursion#Recursion_in_computer_science[^] - it does explain it pretty well.

      The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • S sgunasekhar

        I was just confusing How it works ?

        K Offline
        K Offline
        Keith Barrow
        wrote on last edited by
        #3

        Here you go[^] :) The concept of recursion is pretty much that a method keeps calling itself, in c# this is can be summed up with:

        public void MyMethod()
        {
        MyMethod();
        }

        Note that this will cause an exception because, for practical purposes, the program cannot execute an infinite number of methods without the method ending (technically, there is a stack which monitors method calls, by recursing you add to the stack without removing. As this has limited space, you eventually cause the stack to overflow). So you need to make sure there is an end condition that will always break the loop:

        public void MyMethod(int i)
        {
        if(i < 10)
        {
        i++;
        MyMethod(i)
        }
        }

        looks reasonable. But it will get stack overflow if you start with values of i >= 10. This brings in one of the disadvantages of recursion, that sometimes getting the end condition can be hard. For a simple example it is easy, but for more complicated stuff it isn't. The final thing to remember is, just because you can, it doesn't mean you should. Aside from performance concerns, recursive algorithms can be harder to understand than plain loops (and you can always write a loop as a recursion, and always write a recursion as a loop) so you need to decide whether the recursive solution is neater than a looping one. As an example, I'd loop across a list, but recursively traverse a tree (which can be seen as a recursive data structure).

        “Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed”
        “One of the greatest problems of our time is that many are schooled but few are educated”

        Sir Thomas More (1478 – 1535)

        1 Reply Last reply
        0
        • S sgunasekhar

          I was just confusing How it works ?

          U Offline
          U Offline
          uspatel
          wrote on last edited by
          #4

          you can easily clear concept by assuming factorial example http://www.c4learn.com/introduction-to-recursive-function-in-c.html[^]

          Thanks


          Blog |Articles|Answers

          1 Reply Last reply
          0
          • S sgunasekhar

            I was just confusing How it works ?

            A Offline
            A Offline
            Abhinav S
            wrote on last edited by
            #5

            Recursion ->

            CallMethod()
            {
            while (IsTrue())
            {
            Console.Write("Recursing...");
            CallMethod();
            }
            Console.Write("Done");
            }

            Apps - Color Analyzer | Arctic | XKCD | Sound Meter | Speed Dial

            1 Reply Last reply
            0
            • S sgunasekhar

              I was just confusing How it works ?

              A Offline
              A Offline
              Alan Balkany
              wrote on last edited by
              #6

              Definition of recursion (n) re·cur·sion [ ri kúrzh'n ] [See recursion]

              K 1 Reply Last reply
              0
              • A Alan Balkany

                Definition of recursion (n) re·cur·sion [ ri kúrzh'n ] [See recursion]

                K Offline
                K Offline
                Keith Barrow
                wrote on last edited by
                #7

                I'd google recursion if I were you.

                “Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed”
                “One of the greatest problems of our time is that many are schooled but few are educated”

                Sir Thomas More (1478 – 1535)

                1 Reply Last reply
                0
                • S sgunasekhar

                  I was just confusing How it works ?

                  A Offline
                  A Offline
                  Amarnath S
                  wrote on last edited by
                  #8

                  On the CS106b[^] page, you'll find a Course Reader. This Reader has two chapters exclusively for Recursion, explained very well.

                  1 Reply Last reply
                  0
                  • S sgunasekhar

                    I was just confusing How it works ?

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Try this link[^] sorry - I couldn't resist

                    MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                    1 Reply Last reply
                    0
                    • S sgunasekhar

                      I was just confusing How it works ?

                      U Offline
                      U Offline
                      User 9662891
                      wrote on last edited by
                      #10

                      any one plz help me to upload xml file into the SQLServer2008

                      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