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},...ym)cannot use any additional nodes.
Explain why this is a good or bad data structure.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Author Commented:
Edited text of question.
0
Commented:
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.
0
Systems EngineerCommented:
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.
0
Systems EngineerCommented:
Fuzzy fuzzy fuzzy...
0
Systems EngineerCommented:
:) opppsss i mean Littlecat littlecat littlecat <so it doesn't sound like a porn threat>... :)
0
Author Commented:
This question has a deletion request Pending
0
Author Commented:
I have solved my problem, the rude comments i recieved did not help
thanks
0
Systems EngineerCommented:
This question no longer is pending deletion
0
Systems EngineerCommented:
>>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...
0
Systems EngineerCommented:
Opppsssss, i meant that as a comment, i mean answer...
0

Experts Exchange Solution brought to you by