Search found 23 matches

by polarBody
Sat 19 Sep, 2009 5:23 am
Forum: Programming Help
Topic: [Java] Nodes (Circularly Linked Lists)
Replies: 27
Views: 44938

Re: [Java] Nodes (Circularly Linked Lists)

Yep, you got it. Wow, you learn fast; I'm impressed! I don't really like looking at other code. Getting the idea is the important part. If one can't write their own code, why be a computer programmer? I partially agree with you here. Certainly a programmer should be able to solve any problem that th...
by polarBody
Sat 19 Sep, 2009 3:11 am
Forum: Programming Help
Topic: [Script] The for Loop
Replies: 1
Views: 9920

Re: [Script] The for Loop

This is Python, right? Based on my limited experience with Python I could hazard a guess. The xrange(j, 1, 1) statement effectively creates a range of numbers between j and 1, incrementing by 1. So for each iteration of the for statement, i gets assigned to the next value in this range, until i exce...
by polarBody
Sat 19 Sep, 2009 2:54 am
Forum: Programming Help
Topic: [Java] Nodes (Circularly Linked Lists)
Replies: 27
Views: 44938

Re: [Java] Nodes (Circularly Linked Lists)

I'm glad to see that your starting to see the light! About the for loop, I meant that the entire algorithm could be enclosed in one for loop. But that doesn't exclude the possibility of having other for loops within the body of the main for loop. And yes, you would probably want to have a method tha...
by polarBody
Fri 18 Sep, 2009 10:47 pm
Forum: Programming Help
Topic: [Java] Nodes (Circularly Linked Lists)
Replies: 27
Views: 44938

Re: [Java] Nodes (Circularly Linked Lists)

This algorithm is not recursive. You could enclose it in a for loop that iterates (n-1)! times. Each time this for loop iterates, a different permutation of cities would be produced, from which you could check the distance of the path. All of this would occur within the for loop, without the need fo...
by polarBody
Fri 18 Sep, 2009 5:01 pm
Forum: Programming Help
Topic: [Java] Nodes (Circularly Linked Lists)
Replies: 27
Views: 44938

Re: [Java] Nodes (Circularly Linked Lists)

You could still use nodes with factoradics. Just think of a linked list as a fancy array. If you want to access the ith element of an array, you would write array . If you wanted to access the ith element of a linked list, you would traverse through i nodes. Both arrays and linked lists can be used ...
by polarBody
Fri 18 Sep, 2009 5:12 am
Forum: Programming Help
Topic: [Java] Nodes (Circularly Linked Lists)
Replies: 27
Views: 44938

Re: [Java] Nodes (Circularly Linked Lists)

One thing to keep in mind when you're designing algorithms is that you should try to separate the algorithm from the implementation. In other words, you should first try to come up with a generic algorithm involving the manipulation of an abstract list of objects, and then decide which data structur...
by polarBody
Fri 18 Sep, 2009 4:00 am
Forum: Programming Help
Topic: [Java] Nodes (Circularly Linked Lists)
Replies: 27
Views: 44938

Re: [Java] Nodes (Circularly Linked Lists)

Oh, okay. I see the problem with the algorithm I gave you. This problem is still do-able using singly linked lists and my algorithm, but it would be horribly space-inefficient. To implement it, you would need to create an array of (n - 1)! nodes, run the algorithm so that each element of the array h...
by polarBody
Fri 18 Sep, 2009 1:56 am
Forum: Programming Help
Topic: [Java] Nodes (Circularly Linked Lists)
Replies: 27
Views: 44938

Re: [Java] Nodes (Circularly Linked Lists)

If I understand your question correctly, if given nodes ABCDE, you want to find all possible permutations of BCDE, since A will always be first. Of course, you want a general algorithm involving n nodes, but for now, let's consider just 4 nodes and then generalize. First off, what are the permutatio...