Question: Write a function remove_duplicates(L) that consumes a list L of natural numbers and uses a modification of our binary searching algorithm to replace all elements

 Write a function remove_duplicates(L) that consumes a list L of naturalnumbers and uses a modification of our binary searching algorithm to replace

Write a function remove_duplicates(L) that consumes a list L of natural numbers and uses a modification of our binary searching algorithm to replace all elements that appear more than once with -1, Vour code must run in 0(n10gn) time. Sample: L = [6,1,2,3,3,4,5,6,89823] remove_duplicates(L) => None and L is mutated to [-1,1,2, -1,-1,4,5, -1,89823] Do not import any modules other than math and check. You are always allowed to define your own helper/wrapper functions, as long as they meet the assignment restrictions. Do not use Python constructs from later modules (e'g' dictionaries, commands continue or break, zip, functions with default parameters, anything with set or enumerator, ord, chr, try and except), Do not mutate passed parameters for required functions unless otherwise told to. Use only the functions and methods as follows: - abs, len, max, min, sum, range and sorted 0 Any method or constant in the math module Anybasicarithmetic orcomparison operations(+, -, *, /, H, 94, **, ; >=) Any basic logical operators (not, and, or) These typecasting operators: int(), str()_, floato, bool(), list(), and type() 11: state m ents String or list slicing and indexing as well as string or list operations using the operators above Any string or list methods (see additional notes below) and the in operator input and print as well as the formatting parameter end and method format. Note that all prompts must match exactly in order to obtain marks, so ensure that you do not alter these prompts. Recursion is allowed but inputs will often be larger than recursion can handle so be cautious! Abstract List Functions map and filter and the keyword lambda Single variable loops, specifically for and while loops

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!