Linked List Assignment
Linked List Assignment
The deadline for submissions on both HackerEarth and NTULearn is February 9th, 2024 (Friday)
at 11:59 PM.11:59 PM.
The function should return the index position where the new item was added as follows:
The value 8 was added at index 4
The function does not complete successfully (does not insert the value of 7 to the linked list) hence
it should return a value of -1:
The value 7 was added at index -1
Your function should print the contents of the linked list after it has been created. This function
may be called multiple times for each time your program is running.
Page 1
CE1007/CZ1007 Data Structures Assignment 1
The resulting linked list is: 2 3 5 7
Input an integer that you want to add to the linked list: 9
The resulting linked list is: 2 3 5 7 9
For an example, assume that given two linked lists are LinkedList1 and
LinkedList2: LinkedList1: 1 2 3
LinkedList2: 4 5 6 7
The second list should become empty when the first list is larger than the second list. For
an example, assume that given two linked lists are LinkedList1 and LinkedList2:
LinkedList1: 1 5 7 3 9 11
LinkedList2: 6 10 2 4
A sample input and output session is given below (if the current linked lists are Linked list 1: 1 2
3 and Linked list 2: 4 5 6 7):
Page 2
CE1007/CZ1007 Data Structures Assignment 1
Linked list 1: 1 2 3
Linked list 2: 4 5 6 7
Please input your choice(1/2/3/0): 3
Linked list 1: 1 4 2 5 3 6
Linked list 2: 7
4. Write a C function frontBackSplitLinkedList() that splits the singly linked list into
two sublists – one for the front half, and one for the back half. If the number of elements is
odd, the extra element should go into the front list. The
frontBackSplitLinkedList() prints two lists which contains frontList and
backList.
Page 3
CE1007/CZ1007 Data Structures Assignment 1
Please input your choice(1/2/3/0): 1
Input an integer that you want to add to the linked list: 5
The resulting linked list is: 2 3 5
Please input your choice(1/2/3/0): 1
Input an integer that you want to add to the linked list: 6
The resulting linked list is: 2 3 5 6
Page 4