for (Node* next_pointer)
if ( head!= NULL)
{
Node* curr = new Node (value, head);
curr->next = head;
head = curr;
}
}
Do not allow duplicate values in the list.
I know i need to iterate over each element of the list with a for loop and compare it to the new value...I don't know how to do it!! (code). Could you guys help me please??? any example using a code???
void insertHead(T value) = 0;
{
Node* curr = NULL; //could u explain me this line?
for( curr = head; (curr != NULL)&&(curr->val != value); curr = curr->next); //what do you mean by empty statement?
if( curr == NULL ) //value is new?????
head = new Node(value,head); //???
if ( head!= NULL)
{
Node* curr = new Node (value, head);
curr->next = head;
head = curr;
}
}
Could you explain what you did step by step? I'm a beginner so I really want to understand this stuff.