On the recomendation of "kermi3" I am posting this as a non-code related C++ question in which I need some clarification.
I am having problems understanding the following and want to know if I am correct in my understanding of inserting items in a linked list. I understand with two pointers the order the sequence performed does not matter. I have the two code sequences.
1. newNode->link =q
p->link = newNode
2. p->link = newNode
Question 1; Which of the following is required for inserting to occur correctly in 1.
my thoughts: For 1 to occur correctly I believe
p&q are both required. Q just tells where the new node
will point after inserted with p. Q is also reguired to
conect the new node with the remaining list.
Question 2; in both sequences which of the following MUST be present?
My thoughts:In 1 and 2 am I correct in thinking p must be
present. If it was not or nothing is inserted. Although if p
just occurs the list after p would be lost.
Thanks for your time.