this code results an StackOverFlowError, but I can't pin point where the problem is.
public boolean backtracking(int n, ArrayList<Point2D.Double> R, ArrayList<Point2D.Double> S) {
ArrayList<Point2D.Double> C = new ArrayList<>();
if (R.isEmpty()) return true;
else {
for (int i = 0; i <= R.size() - 1; i++) {
Point2D.Double currentPt = R.remove(i);
S.add(currentPt);
Ellipse2D.Double circle = new Ellipse2D.Double(currentPt.x - r, currentPt.y - r, r * 2, r * 2);
for (int j = 0; j <= R.size()-1 ; j++){
if (circle.contains(R.get(j))){
C.add(R.remove(j));
}
}
backtracking(n+1, R, S);
if (!C.isEmpty()) R.addAll(C);
R.add(S.remove(S.size() - 1));
}
}
return false;
}
Ps. this "should" be a method that calculates the minimum number of circles that is needed to cover all the points in the R array list.