Question: C. (15 points) Write a recursive function that will copy the items from the original list into two output lists. Every even item from the

C. (15 points) Write a recursive function that will copy the items from the original list into two output lists. Every even item from the original llist will be copied into the first llist, while every odd item will be copied into the second llist (alternating the copy process between the two lists). For example, if the original llist org [1, 3, 5, 6, 8, 9, 11], then the output lists will be out1-(1, 5, 8, 11] and out2 [3, 6, 91 The use the the count:int to decide if the item's position in the list is odd or even. Increment the count in each recursive function call and use the mod function to check if the count value is odd or even. I do not care about the order of the output llists - it might be easier to split the org - [1, 3, 5, 6, 8, 9, 11], into the output llists outl-[11, 8, 5, 1] and out2-[9, 6, 3] int mainl) //If needed, see the LList code in appendix. tlade orgnull: Node outi -rull: Node out2 null: insertHead(i1, sorg) i insertHead (9, sorg) i insertHead i8, org insertHead (6, Sorg) insertHead5, org insertHead i3, sorg) insertHead (i, korg) i splitlistlorg, souti, sout2,) void splitList (Node org, Node+outi, Node * out2, int count) D. (2 points) Label the base case(s) and recursive case(s) in comments in the function above. C. (15 points) Write a recursive function that will copy the items from the original list into two output lists. Every even item from the original llist will be copied into the first llist, while every odd item will be copied into the second llist (alternating the copy process between the two lists). For example, if the original llist org [1, 3, 5, 6, 8, 9, 11], then the output lists will be out1-(1, 5, 8, 11] and out2 [3, 6, 91 The use the the count:int to decide if the item's position in the list is odd or even. Increment the count in each recursive function call and use the mod function to check if the count value is odd or even. I do not care about the order of the output llists - it might be easier to split the org - [1, 3, 5, 6, 8, 9, 11], into the output llists outl-[11, 8, 5, 1] and out2-[9, 6, 3] int mainl) //If needed, see the LList code in appendix. tlade orgnull: Node outi -rull: Node out2 null: insertHead(i1, sorg) i insertHead (9, sorg) i insertHead i8, org insertHead (6, Sorg) insertHead5, org insertHead i3, sorg) insertHead (i, korg) i splitlistlorg, souti, sout2,) void splitList (Node org, Node+outi, Node * out2, int count) D. (2 points) Label the base case(s) and recursive case(s) in comments in the function above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
