Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lists and Dictionaries (6 points): WP1 Complete the implementation of max_repeat_counts, which takes a non-empty list and returns a dictionary containing a key for each
Lists and Dictionaries (6 points): WP1 Complete the implementation of max_repeat_counts, which takes a non-empty list and returns a dictionary containing a key for each element in the list, with a value corresponding to the maximum number of times the element repeats in succession) E.g., max_repeat_counts (1, 2, 2, 2, 2]) returns (1: 1, 2: 4 E.g., max_repeat_counts ([3, 3, 4, 4, 3, 4, 4, 4]) returns 13: 2, 4: 3 Insertion Sort (6 points): Consider the following reversed insertion sort implementation which prints the contents of the list at the start of each inner iteration: def rev insertion sort (lst) for i in range(1, len(1st)): for j in range(i, 0, 1): print (1st) if lstlj] # print list lst[j-1]: 1st [j] contents 1st [j-1], 1st [j], 1st [j-1] else: break WP2 Show the list contents, in order, displayed by all calls to print when rev insertion sort is called with the input lst [2, 1, 3, 4, 5]. The first output is already filled in for you; you may not need all lines Array-backed List (6 points): Complete the implementation of the array-backed list method remove span which should remove the first span of adjacent elements with the specified value from the list E.g., remove span (2) on [1, 1, 2, 2, 2, 3, 3, 2, 2] results in [1, 1, 3, 3, 2, 2] E.g., remove span (5) on [3, 3, 4, 4, 5, 5, 5] results in [3, 3, 4, 4]. If the list does not contain the specified value, a ValueError should be raised Your implementation should assume elements are stored in a Python list referenced by self.data, which you can only manipulate as an array (using the rules given in class) You may not use any other ArrayList methods WP3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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