Since I don’t have a machine to test this I kindly need your help here.
-
If I assign
L.head = NULLwill theLgets empty because there is
nohead? -
If I assign
L.head = L.next.next(3rd node) the previous two nodes
will be as a Garbage Collector (assuming using Java) correct?
My attempt to write a method cutToInteger for the photo below is the following, correct it if I’m wrong:
void cutToInteger (IntSLList L , int n){
IntSLList tmp =L.head ;
while( tmp != NULL || !tmp.into.equals(n)){
tmp=tmp.next;
}
L.head = tmp;
}
The implementation seems easy but the logic of the nodes becoming a garbage data to get removed always confuses me.

UPDATE: Here is the Question for the above screenshot
A method void cutToNumber(IntSLList L, int n) that cuts an integer singly linked list L starting from the head until it reaches integer n. If n is not in L, the list becomes empty.
in your loop it should be
&&operator rather than||,otherwise it always will stop only at the end of the link.nisint, so you have to use==\!=operators for compare it with otherint.the method should be something like :