the algorithms in my homework

hello

1. A cost-map contains M*N cells, we have the cost rate for each individual cell.

2. The path is defined as a sequence of cells that connect to each other directly.

3. If two cells are in the same row or column, and there is no cell between them, these two cells are defined as directly connected.

4. The cost of a path is the summary of all the cells’ costs involved.

question:

you are required to find out a cheapest path from one specified cell to another.

i have designed several class architecture as follow,maybe they are not complete,but it is not important,what i more care about is:how can i implement the algorithm to find the cheapest path?,who can give me the code snippet about the algorithm to get the cheapest path?or where can i find it?

thank you!

**********************************************************************

public class Map{

int A;

int B;

public Cell getCell(int row, int col){

}

public Cell getStartCell(){

}

public Cell getTargetCell(){

}

}

A: is the row number of the map

B: is the column number of the map

getCell returns the Cell with row and column specified. The start index is 0.

getStartCell and GetTargetCell return the start and end cell of the problem.

public class Cell{

int row;

int col;

public int getCost(){

}

}

public class Trace{

public int getTraceLength(){}

public Cell getCell(int n){}

public int getCost(){}

}

getTraceLength returns how many cells are involved in this trace.

getCell returns the number n cell in this trace.

getCost returns the total cost of this trace.

[1840 byte] By [zhebinconga] at [2007-9-30 0:52:33]
# 1

>

> i have designed several class architecture as

> follow,maybe they are not complete,

Obviously.

> but it is not important,

Yes it is. If you'd done more you might have gotten some help. What you're asking is: "Will someone do my homework for me?" That's not what the forum is about.

> what i more care about is:

I'll bet it is.

how can i implement the algorithm to find the cheapest path?,

Write more Java code.

> who can give me the code snippet about the algorithm to get the cheapest path?or where can i find

> it?

Try a Google search or go to the library. I'm sure the algorithm is in a book somewhere. - MOD

duffymoa at 2007-7-16 5:25:19 > top of Java-index,Other Topics,Algorithms...
# 2
Obviously you've never heard of Dijkstra. - MOD
duffymoa at 2007-7-16 5:25:19 > top of Java-index,Other Topics,Algorithms...
# 3
Just to translate the harsh words of duffymo:Search the web for Dijkstra. (Go to www.google.com, type in dijkstra in the search field, and push the button)You will then get all the answers you need.
Ragnvald_id2a at 2007-7-16 5:25:19 > top of Java-index,Other Topics,Algorithms...