Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Precalculus

Authors: Jay Abramson

1st Edition

1938168348, 978-1938168345

More Books

Students also viewed these Programming questions

Question

Am I just skimming over the problem?

Answered: 1 week ago