Chloemorgan
asked on
linked lists help
Having problems implementing circular linked lists.
Let X=(x1,x2,...xn) and Y=(y1,y2..ym) be two circular linked lists. Need to write a algorithm to merge the two lists together to get linked list
T=(x1,y1,x2,y2...xm,ym,x,{ m+1},...xn )if m<n and T=(x1,y1,x2,y2,...,xm,yn,y {n+1},...y m)cannot use any additional nodes.
Explain why this is a good or bad data structure.
Let X=(x1,x2,...xn) and Y=(y1,y2..ym) be two circular linked lists. Need to write a algorithm to merge the two lists together to get linked list
T=(x1,y1,x2,y2...xm,ym,x,{
Explain why this is a good or bad data structure.
Hi.
I'll not solve your problem, but I'll give you the direction.
You have two circular linked list, and pointers to the first element.
What you have to do is to save the pointer to the first node of each list, and start passing through the two lists togather. Link them togather by changing the pointers, but always check that you haven't returned to the first node of list. If list Y finished before list X, you don't have even to close the list, as the last element would be xn, and it points to x1.
If the X list ends before the Y list, you have to pass through the Y list in order to close the last node (ym) to x1.
Start implementing this small algorithm, and I'll help you if you got any problems in the code YOU will write.
As for the question (good or bad) you have to answer it yourself, as I've already finished my DataStructures course.
Fuzzy.
I'll not solve your problem, but I'll give you the direction.
You have two circular linked list, and pointers to the first element.
What you have to do is to save the pointer to the first node of each list, and start passing through the two lists togather. Link them togather by changing the pointers, but always check that you haven't returned to the first node of list. If list Y finished before list X, you don't have even to close the list, as the last element would be xn, and it points to x1.
If the X list ends before the Y list, you have to pass through the Y list in order to close the last node (ym) to x1.
Start implementing this small algorithm, and I'll help you if you got any problems in the code YOU will write.
As for the question (good or bad) you have to answer it yourself, as I've already finished my DataStructures course.
Fuzzy.
Merge Simpson???
The merge, could be simple...
You have L1 and L2... and want to merge them in to another, i assume you have the Insert procedure, so why don't you "create" the new merged link on the fly using the links allready done...
i mean i don't get it what's the problem, how do you input the data??? with a Insert procedure, right??? well create the Merged link with the same procedure, but insted of inputting by the KB, use the data in the allready links, and swaping each item on each link.
The merge, could be simple...
You have L1 and L2... and want to merge them in to another, i assume you have the Insert procedure, so why don't you "create" the new merged link on the fly using the links allready done...
i mean i don't get it what's the problem, how do you input the data??? with a Insert procedure, right??? well create the Merged link with the same procedure, but insted of inputting by the KB, use the data in the allready links, and swaping each item on each link.
Fuzzy fuzzy fuzzy...
:) opppsss i mean Littlecat littlecat littlecat <so it doesn't sound like a porn threat>... :)
ASKER
This question has a deletion request Pending
ASKER
I have solved my problem, the rude comments i recieved did not help
thanks
thanks
This question no longer is pending deletion
>>the rude comments i recieved did not help
The RUDE??? ??? ???
Now i got it, you don't wanna pay, fine, but next time, think about it, you're in my list pal...
The RUDE??? ??? ???
Now i got it, you don't wanna pay, fine, but next time, think about it, you're in my list pal...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Whatboy, that comment i made was npot referred to you. Sorry if you took it that way. Yes you did help me thanks
ASKER