Thread: trouble with recursion

  1. #16
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    That's an excellent explanation - comprehensive and detailed. The only complaint I have is against:

    (1) make absolutely sure that every time the function calls itself, it's calling itself on a STRICTLY SMALLER subproblem

    While that generally will work, there are cases where it doesn't: namely, those cases where there is no calculable end to the recursion. Take for example a floodfill algorithm: For each adjacent pixel that is of the same colour, you recurse down that path setting the new colour as you go. Note that this does not break the problem into smaller sub-problems; although it branches, the problem is identical at each step in the recursion (unless you count the overall state of the program at which the function is executed) until at some point none of the surrounding pixels are of the target colour, and the function then returns.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #17
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003

    I agree that is a good detailed explination.
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  3. #18
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Manassas, VA USA
    recursion is very recursive in nature
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Template Recursion Pickle
    By SevenThunders in forum C++ Programming
    Replies: 20
    Last Post: 02-05-2009, 09:45 PM
  2. Trouble with recursion...
    By headbr in forum C Programming
    Replies: 2
    Last Post: 08-01-2008, 06:14 PM
  3. Recursion program trouble... ?
    By Beachblue in forum C Programming
    Replies: 7
    Last Post: 06-19-2008, 01:43 PM
  4. #include recursion trouble
    By ichijoji in forum C++ Programming
    Replies: 4
    Last Post: 07-01-2003, 05:15 PM
  5. a simple recursion question
    By tetra in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2002, 10:56 AM