if I enter amount of linked list is 3 : x1 = 3, x2= 1, x3=2 that print : 2 1 3(it really true) but max=2, I could not find bug, This is my code:
int max(Node l){
int max = 0;
if(l == null) return 0;
else
{
if(l.data > max){
max = l.data;
l = l.next;
}
else return max(l.next);
}
return max;
}
int max(){
return max(head);
}