Sunday, July 12, 2009

Dijkstra's Continued

I was thinking about this particular program all week. The way I had it set up was bad. Really bad. The short of the long for what I had, it would've done an N long search for the entire graph each time it called costFrom and directionAt. In other words, it was an awful idea. I hate it even though I thought it up. After a little chat with my boss, he imparted words of wisdom on how I could do better. I feel ashamed I didn't think of the first suggested he gave. That would be a 2d array that would store my data (d, pi) in each index corrisponding to the x and y cordinates on the GridCoordinate. The next suggestion was use of a hash table. This was slightly less obvious but still... I should hang my head in shame for not thinking of it. This will use the GridCoordinate as a key and the DNode (my class that will hold d and pi) is the value.

After poking at the x and y coordinates of the gridcor's I found that all the values are greater than or equal to 0 (in this case it was 0 to 19). For now I will set aside my awful (and probably not working) linked list version and do the grid version. It will probably lead me to a working solution faster than my first method. I'll go back to my first iteration later.

Fortuantely, most of the code is the same from my linked list attempt. So not much is truely lost. Time to just sit down and work on it.

Wrote down a majority of the code, but will test it more later. I'm having null pointer exceptions. Figures.

PS: Professor, Stephen has been trying to get in touch with you about the next assignment.

No comments:

Post a Comment