Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java
Hello Friends. How can I obtain the tracking of snakelike array within loops as shown in figure below?
 
[IMG]http://i49.tinypic.com/2ev3o94.png[/IMG]
Posted 15-Nov-12 3:57am
BerkanH299
Comments
Sergey Alexandrovich Kryukov at 15-Nov-12 9:33am
   
First of all, as this picture does not show one continues path through the array, it's not quite clear what is required. This is rather a description of some partial order. So, not clear what you want to achieve. To perform some operation on the array in certain order? But, due to having a partially ordered set, there is more than one possible path. So, what exactly you want to achieve? Do always you need to work with an array 6x8? How about other cases?
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question.
 
Here is the idea: showing the picture does not mean definition of the problem. Moreover, showing one particular example is also not a definition of the problem. By an example, it's usually possible to find some different algorithms doing different things is some general case which is not formally described.
 
The code is pretty much like a statement in mathematics: it does not just express some idea, more or less vague. It always defines something in an absolutely certain way, even when this absolute level of certainty is not required by some practical purpose. Every such definition or algorithm hold the notion of infinity in its depth: it defines some invariant behavior, which does not depend on how and when the code was compiled, how many times executed (it it is stateless, of course), on what what CPU, at what time, etc. It always define some invariant behavior, without any ambiguity. So, the requirements to the algorithm should meet this level or certainty.
 
That said, this is one of the typical cases, when the solution of the problem is nearly equivalent to its strict formulation. Here is what you have to do: formulate the problem in the form of text fully understandable to all qualified readers, in a fully unambiguous way. You will see that it would require strict mathematical language. As soon as you do it, you will see that the algorithm is already there — you only need to translate it from you declarative language to some imperative language. Such as Java.
 
There are very many cases, when such translation itself is extremely difficult; and there is a good number of unsolved problems, well known in the world. But not in your case. I'm pretty sure in your simple case this is all what involved, there is nothing else.
 
Consider I gave you a universal algorithm Smile | :) for solving of unlimited number of similar problems: formulate it strictly, and immediately see the solution.
 
—SA
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100