$24
Topic
linked lists
Recitation Instructions
There are two programs given for this recitation. Both are required.
Complete Program ONE first, have your lab worker approve it for a grade and then, if Program ONE was approved, proceed to Program TWO.
Complete Program TWO, then have your lab worker approve it for a grade.
Again, both programs are required for this recitation.
Recitation Project(s)
Program ONE
Create and test the function(s) needed for this problem.
Splice a singly linked list of ints into another list of ints given a pointer to the node that you will insert after.
E.g.:
If the original list was
5791
and the list to splice in was
632
and if the function is passed a pointer to node containing the 7 in the original list, the resultant list would be
5763291
Note that the 632 list was spliced into the original list after the node containing the 7 .
1/3
2/28/2016 rec11: Linked List Basics
Requirements:
you must use this attached provided code to work from the spliceinto function must be void
Assumptions:
the function will not attempt to splice before the first node in the original list
Considerations:
Do not use any other code from the course's sample code
can we use the code that splices a list between two nodes to splice a list after the last node?
Testing:
print both lists before the splice and print the original list after splicing.
Program TWO
Create and test the function(s) needed for this problem.
Given two lists of ints, is the second list a sublist of the first?
E.g.:
Situation: Second list is a sublist of the first.
If the list to be searched is 5763291
and the list to be looked for is 6329
the function should return a pointer to the node 6 in the list to be searched.
Situation: Second list is not a sublist of the first.
If the list to be searched is 5763291
and the list to be looked for is 623
the function should return nullptr.
Situation: Second list is not a sublist of the first.
If the list to be searched is 5763291
2/3
2/28/2016 rec11: Linked List Basics
and the list to be looked for is the function should 2914 return nullptr. Requirements:
the isSubList function must return a pointer to the node where the sublist starts in the searched list or nullptrif not found
Considerations:
what if there is more than one match of the sublist
Testing:
print the lists
print the list returned by the isSubList function
See the Sample Output
file:///home/jsterling/Dropbox/Courses/CS1124/CS1124%20Recitations/16S/rec11/rec11.html 3/3