Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) [90 marks] Write a program that Splits a list into two halves. The function split() must modify the original list and return a
a) [90 marks] Write a program that Splits a list into two halves. The function split() must modify the original list and return a pointer to the second half of the list, e.g., L=1234 must be 1 2 after execution, and the function must return 3 4. . o If the size of the original list is odd, add a node with value 99 to the index 4 (recall that the first node is at index 1 and the dummy/zeroth node is at index 0) so that the list is even-sized now. If there is no index 4, add 99 to the tail. Merges two lists such that list2 begins right after list1. b) [10 marks] State the worst-case time-complexities of both two parts above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
a python class Node def initself value0 nextNone selfvalue value selfnext next def splithead slow he...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started