Question: I need help with these linked list data structure programs with Python!!! In order to work with these programs, a file needs to be imported.

I need help with these linked list data structure programs with Python!!! In order to work with these programs, a file needs to be imported. All the specs are going to be provided below:

I need help with these linked list data structure programs with Python!!!In order to work with these programs, a file needs to be

5 partitiomlist (head) This is a little like splitiisto from the Short problem, except that, instead of splitting the list into two by cutting it into the middle, you will now build two lists to return, using alternate values. The rst value in the input list should be returned at the head of the rst new list; the second value should be the head of the second list. Keep on alternating from there, putting one new value on the rst list, and one on the second. (But remember that the length of the input list might be odd.) Example Suppose you have the following input list: 10 -> 13 -> -1 -> 1000 > 0 It should return the following two lists: 10 -) -1 -) 0 13 -) 1000 6 accordion_4(head, start_pos) This function takes a linked list, and removes three out of every four nodes; the rst node that it returns is given by the start_pos parameter. The start_pos gives the index of the rst node to keep: if start_pos is zero, keep the head; if start_pos is one, then keep the node immediately after the head, and so on. If the list doesn't have enough nodes to satisfy the start_pos (including, of course, an empty list], then simply return an empty list. You may assume that start._pos is nonnegative (meaning that zero is OK, and any positive number but that negative numbers are not allowed). After the start_pos, keep every fourth node, but discard the other three. For instance, if start._pes is 1, then keep the second, sixth, tenth nodes, and so on. The surviving nodes should be linked together into a list; all of the other nodes are simply discarded (presumably to be garbage collected). 6.1 Example If you have a linked list 10 -) 11 -) 17 -) 19 -> 23 -> 31 -> 37 -> 43 -> 53 -> 59 and start_pos=2, then you should return the following: 17 -) 37 7 pair(list1 , list2) This function takes two lists, which may be of different lengths [either or both of them might be empty). It builds new ListHode objects, where the value of each one is a tuple, consisting of one value from the rst list, and one value from the second list, in the same order as they existed in those input lists. If the lists are different lengths, then the length of the returned list will be equal to the length of the shorter one. 7. 1 Special Requirement This sort of problem generally requires you to add new nodes at the end of the list (\"adding to the tail\") instead of the simpler \"adding at the head." Some students decide to only keep the head pointer; they thus have to iterate through the entire list, every time that they want to add a new element. Can you explain why this sort of algorithm would run in 0(712) time? A far better solution is to keep a second pointer, called a \"tail pointer," which helps you keep track of where you're inserting new values. Then, the process of inserting many elements into the list takes C(11) tirne. Can you explain why? So here's the requirement: you must not iterate from the head every time you want to append to a list. Instead, you must use the tail pointer (or some equivalentlyefficient mechanism). If you do the 0(112) insertion on this problem, then you will lose 10 points off your total score for this assignment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!