- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Wave)
Given the following two lists:
View attachment 3442
what could we do, so that the first list contains both the elements of the first and the second list, sorted? (Thinking)
I wrote the following algorithm:
But, then it is like that:
View attachment 3443
The next fields of $1$ and $5$ point both to $100$, but it shouldn't be like that... (Worried)
What could we do? (Thinking)
Given the following two lists:
View attachment 3442
what could we do, so that the first list contains both the elements of the first and the second list, sorted? (Thinking)
I wrote the following algorithm:
Code:
pointer *P=L1, *Q=L2,n;
while ((P != '\0') && ( Q != '\0')){
n->data=Q->data;
n->next=P;
Q=Q->next;
}
But, then it is like that:
View attachment 3443
The next fields of $1$ and $5$ point both to $100$, but it shouldn't be like that... (Worried)
What could we do? (Thinking)