Answer:
Java program is explained below
Explanation:
import java.util.HashSet;
import java.util.Map;
import java.util.TreeMap;
public class TruckRace1 {
public static HashSet<String> getPIDs (Map<String,String>nameToPID ){
HashSet<String> pidSet = new HashSet<>();
for(String ids: nameToPID.values()){
pidSet.add(ids);
}
return pidSet;
}
public static void main(String[] args) {
Map<String,String> pids = new TreeMap<>();
pids.put("John","123");
pids.put("Jason","124");
pids.put("Peter","125");
pids.put("Alice","126");
pids.put("Peny","129");
HashSet<String> ids = getPIDs(pids);
for(String id:ids){
System.out.println(id);
}
}
}