recursive merging linked list - HELP!!

hey i've just started learning building structures in c++ and they gave us an exercise of writing a recursive merge code of linked lists - just merging without sorting... i don't even know how to start this is how i started so far.... i know that the break in the recursive function is when i get to the end of the first list and then to start linking the second list...

as you can see i wrote a function that uses recursive function...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
LIST merge3(LIST lst1, LIST lst2)
{
	LNODE* curr1 = lst1.head;
	LNODE* curr2 = lst1.head;
	LIST mergeList;
	mergeList.head = NULL;
	mergeList.tail = NULL;

	mergeList.head = merge33 (curr1, curr2); // connecting recursive func

	return mergeList;
}

LNODE* merge33 (LNODE* n1, LNODE* n2)
{
	if (n1 == NULL)
	{
		return n2;
	}

	return merge33 (n1->next, n2);
}


if someone can guide me how to even start looking at it i mean am i on the right direction or am i totally off of it....

THANXS!!
Last edited on
Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.