This is the reason why i hate being beginners

I am in attempt to solve the traveling salesmen problem despite that i am just in beginner programming class.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>

using namespace std;

void greedyfunc(void);
double TSP(void);
void checkingvalid(void);
int size = 5;
int dummyroad[size];
bool myarray[5];

int main(void)
{
	;
}

void greedyfunc(void)
{
	int index;
	for(int i=1;i<index;i++) 

	if (vals[i] < loVal)
		loVal = vals[i];
}


}

double TSP(first.parent, second parent)
{
	int index;
	for(int i = 0;i<index;i++)
	if(first.parent.i == second.parent.i)
		return (first.parent.i);
	else if (first.parent.i > second.parent.i)
	{
		 greedyfunc(second.parent.i);
	}
	else 
	{
		 greedyfunc(first.parent.i);
	}
}




void checkingvalid(void)
{
	int num;
	int index;
	for(int i = 0; i < index; i++)
	{
		;//connnecting routes adding 1 each time, add 2 the first time. 
	}
	while (num != size)
		delete route; //remember to declare it. 
}


As you see i am NO WHERE near to complete. Now here's my approach.
1)assuming the array[5] is initialized with numbers, the numbers represent the length it takes it travel from each of the 5 cities, so right away you can imagine a 5 by 5 symmetric matrix.

2) my problem is i don't know how to start with cities, i recognize the city by length, as you see in line 29 i am trying to compare each parents route segment, and if the segment is the same(meaning if both routes have point A to point C) the new child route will also have that segment. Within that tsp function, i will also call greedyfunc, where greedyfunc is just a function that connect the closest city which i have no idea how to code it )=.

This method is call genetic algorithm, i know there are some code out there but i don't understand and i would like to stay in my approach. anyone can help me with it i will be greatly appreciated.
anyone can help me please?
Topic archived. No new replies allowed.