I am new to recursion and want to know if the below code can be called a recursive function,although the function is calling itself not sure whether it satisfies the condition to have base and recursive cases.
Below function sorts flight tickets based on starting point of the trip ( the trip is assumed to have multiple transitions and tickets are shuffled like ABC-> EFG, XYZ-> MNO, EFG -> KLM , KLM->XYZ).
public List<Ticket> sortTickets(List<Ticket> shuffled, String source, int n) {
if (sortedList.size() != shuffled.size()) {
n = (n < 0) ? shuffled.size() - 1 : n;
if (shuffled.get(n).source == source) {
sortedList.add(shuffled.get(n));
source = shuffled.get(n).destination;
return sortTickets(shuffled, source, n - 1);
} else {
return sortTickets(shuffled, source, n - 1);
}
} else {
return sortedList;
}
}