Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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


image text in transcribedimage text in transcribed

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. Your code must run in O(nlogn) 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 Any method or constant in the math module Any basic arithmetic or comparison operations (+, * /, //, %, ** , =) Any basic logical operators (not, and, or) These typecasting operators: int(), str(), float(), bool(), list(), and type() if statements 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

Step: 1

To solve the problem we need to implement the removeduplicatesL function that 1 Uses a modified bina... 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_2

Step: 3

blur-text-image_3

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students explore these related Programming questions