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 :)