Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write the function remove_smaller (S,k) that receives a set of integers S and an integer k and removes from S all items that are

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1. Write the function remove_smaller (S,k) that receives a set of integers S and an integer k and removes from S all items that are smaller than k. 2. Write the function no_duplicates (L) that receives a list of integers L and returns a list containing the result of removing duplicate elements in L. The elements must appear in the same order they appeared in L; if an element appears multiple times in L, only its first appearance should be included in the returned list. For example, no_duplicates ([3,6,2,3,1,2,7,3]) should return [3,6,2,1,7]). Use a set to enable the function to run in O(n) time. 3. Write the function sum_of_two (L,s) that receives a list of integers L and an integer s and determines if there are two integers i and j in L such that i+j=s. If the items exist, it should return a list containing the two items; if they don't exist, it should return an empty list. Your solution must run in time O(n). 4. Write the function repeated_substrings (S,m) that receives a string S and an integer m and returns a list containing all the sub-strings of length m that appear more than once in S. Your solution must run in time O(n)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

What is american history?

Answered: 1 week ago

Question

KEY QUESTION Refer to the table in question

Answered: 1 week ago