Algorithm help (Changing from Recursive to Non Recursive)

This is a discussion on Algorithm help (Changing from Recursive to Non Recursive) within the C++ Programming forums, part of the General Programming Boards category; Working on a program to create a "map" of interconnecting sectors. The rules as set forth by me: 1) Each ...

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

    Algorithm help (Changing from Recursive to Non Recursive)

    Working on a program to create a "map" of interconnecting sectors.

    The rules as set forth by me:
    1) Each sector can connect to up to X number of other sectors (User defined during execution)

    2) Every sector must be accessible via other sectors by every sectors. Ex: Sector 100 must be able to get to sector 302 either directly or by going through other sectors.

    3) The sector numbers have no bearing on how they are arranged.

    4) Sector A can attach to Sector B without Sector B attaching to Sector A. Sector A and Sector B can mutally attach to each other. Ex: Sector 100 may be accessable through sector 109 without sector 109 being accessable through sector 100. However it allowed for sector 100 and 109 to be accessable through each other.

    My problem comes with verifing number 2. Currently I'm using a recursive algorithm to verify. The problem with that is when I have a large number of sectors (100,000) my recursive depth gets to be about 52,000 with 16 bytes passed each time. I'm looking at this and I know there is a non recursive method but I'm just not seeing how. Anyone have any ideas?

    Attached is the source code and sample output of the sectors. I know there are some stylist issues, however if you do see something major please feel free share

    Note: Number 4 hasn't been implamented as of yet. I'm waiting to take care of the verification problem first.

    Note2: Silly board won't allow attachments with a .cpp extension. Gonna have to rename it
    Attached Files Attached Files

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Nevermind. Finally an idea came to me using linked lists.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recursive Stack Algorithm Maze Solver
    By unrestricted in forum C Programming
    Replies: 0
    Last Post: 09-04-2007, 04:11 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  3. recursive algorithm
    By vienne in forum C Programming
    Replies: 4
    Last Post: 07-18-2004, 07:03 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21