-
Notifications
You must be signed in to change notification settings - Fork 0
/
h9.txt
36 lines (24 loc) · 1.03 KB
/
h9.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
1. (a) VIN number because there would be no chance of repeating values or it changing.
(b) The other data members could change or be repeatable causing them to be less suitable.
2. (a) [1 2 4 6 3 5 7] Queues: [1] -> [2 4 6] -> [4 6 3] -> [6 3 5] -> [3 5 7] -> [5 7] -> [7]
(b) [1 2 3 6 5 7 4]
Stack:
[7] <-- 5 to 7, back track to 5, back track to 6, back track to 3, back track to 2, back track to 1
[5] <-- 6 to 5
[6] <-- 3 to 6
[3] <-- 2 to 3
[2][4] <-- 1 to 2, 1 to 4
[1] <-- 1 start
3.
public boolean isValidColoring(MapRegion startPos) {
for(int i = 0; i<startPos.getNeighbors().size(); i++){
if(startPos.getNeighbors(i).getColor().equals(startPos.getColor())) return false;
}
startPos.setIsValid(true);
for(int i = 0; i<startPos.getNeighbors().size(); i++){
if(startPos.getNeighbors(i).getIsValid() != true) {
startPos.setIsValid(isValidColoring(startPos.getNeighbors(i)));
}
}
return startPos.getIsValid();
}