algorithm to unlock this problem...

imagine a 4x4 matrix filled with letters, how can i make an algorithm that will give me every possible word ,with four letters, made with the letters of the matrix, knowing that each letter may only associate with ones next to it (imagine mine sweeper) the return values should be in the form of a string per word... preferably a linked list of objects with a string inside or a string array...
if someone could make me the class that would do the job i would be very grateful
(ps: i think its with a Heap, but i cant imagine how)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

not a class or algorithm, but a bit of logic:

with a 4*4 matrix you ghave 4*4 = 16 letters that may be the first letter
for each of those you can then make 'all possible 4-step paths from there'. there is a limited number of those (permute multiple nsew), though some need to be pruned depending of which of the 16 starting location you begin at (and wheater you permit the path to double back ('ewew').

regards JakobA
omega-t-kAuthor Commented:
i know that in teory its quite simple... im not that dum :P the problem is the implementation of the teory... i need an algorithm that does the permutations and belive me it isnt that obvious.. :) imagine trail starting at one of those letters, and each of the letters next to it are possible paths. and for each steap you give you have another number of possible paths... now what i need is an algorithm that wil give me all the 4 letter words that you ca make starting at one letter. i give a starting letter to the imput and the algorithm gives me all the possibilities! in the form of four letter strings... get it? ;)
I think we can agree that the basis is a recursive function going 4 steps (levels)

a useful support-method would be a  canIGoInThatDirection metod to be called before taking each step. in that method you would collect all the rules (not outside board, not same letter revisited, and maybe more). Dont find same path twice are implicit in the recursion:

take step;
for i = north, south, east, west
     if ( iCanGoInThatDirection ) {
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

PS:  the reason I am not more specific is that this is a typical homework problem, intended to teach you logical thinking.
omega-t-kAuthor Commented:
lol you´re quite right... but belive me... i´ve studied! and the reason i´ve asked for help is because i cant do the complete work because im missing that part,that algorithm... the rest of problem is done... well thnks anyway :) ill leave this open for now and if im not given a better answer, i will accept that one :) it as been some help, althought the coding is strange... im using low-level java and i dont understand the
"for" implementation :/ we use java as if using C "for(bla;bla;bla)"
if you could explain that, i would be gratfull. thanks for the help!
It is called 'pseudo code', meaning that it is not really code, just thinking that look a bit like code.
an alternative for
  for i = north, south, east, west
would be
  for ( each possible direction )

later it can then be turned into a syntactically correct for statement
If you make a start and show the code (even if it di not work) we can point out errors and maybe even suggest improvements as long as it is not "handing you the algorithm on a silver platter".

regards JakobA

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omega-t-kAuthor Commented:
im already on the tracks! and first in the class to do it ;) ive already made the algorithm the rest is simple tnks for the help
sounds good :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.