E[ ] stuff = new E[MAX]; // Won't work.
Instead use this:
E[ ] stuff = (E[ ]) new Object[MAX];
This will give you an unchecked cast warning, but that is o.k.
Posted Feb 1:
DFS search: (0,0) (1,0) (2,0) (3,0) (3,1) (3,2) (2,2) Length of path: 6 Number of cells visited: 16 BFS search: (0,0) (0,1) (0,2) (1,2) (2,2) Length of path: 4 Number of cells visited: 14For bigmaze2.txt:
DFS search: (0,0) (1,0) (2,0) (3,0) (4,0) (4,1) (5,1) (5,0) (6,0) (6,1) (7,1) (8,1) (8,2) (7,2) (7,3) (8,3) (9,3) (9,4) (8,4) (7,4) (7,5) (6,5) (6,6) (7,6) (7,7) (7,8) (7,9) (8,9) (8,8) (9,8) (9,9) (9,10) (9,11) (8,11) (8,12) (8,13) (9,13) (9,14) (9,15) (8,15) (8,16) (7,16) (7,17) (8,17) (8,18) (8,19) (8,20) (9,20) (9,21) (9,22) (9,23) (9,24) (9,25) (9,26) (8,26) (8,27) (8,28) (9,28) (9,29) Length of path: 58 Number of cells visited: 100 BFS search: (0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (1,5) (1,6) (1,7) (2,7) (3,7) (3,8) (3,9) (3,10) (3,11) (3,12) (2,12) (2,13) (3,13) (3,14) (3,15) (2,15) (2,16) (2,17) (2,18) (3,18) (3,19) (3,20) (3,21) (4,21) (4,22) (5,22) (6,22) (6,23) (6,24) (6,25) (6,26) (6,27) (6,28) (7,28) (7,29) (8,29) (9,29) Length of path: 42 Number of cells visited: 300
Posted Mon Feb 8:
public class BinaryHeap <E extends Comparable<? super E>>then also the example on p. 212 of a constructor that allocates an array of Comparable:
array = (E[]) new Comparable[MAX_SIZE];
Posted Wed Feb 10: