I'm learning linked lists in C++.
In an exercise I have to duplicate H time a give item.
So I thought in this method:
void duplicaNodo(int item, int &H, Pnodo &L){
//duplica un nodo H volte, scorrendo tutta la lista
Pnodo Temp, Temp2;
if(L!=NULL){
if(L->info==item){
for(int i=0; i<H; i++){
creaNodo(item, Temp);
Temp->next=L->next;
L->next=Temp;
}
Temp2=Temp->next; //Delete this
duplicaNodo(item, H, Temp2->next); //to stop at first occurrence
} else {
duplicaNodo(item, H, L->next);
}
}
}
Can you give some suggestions or I did it right?