Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

where are the unit test? Problem: Find Pairs Given a list of unique integers and a target integer, find all pairs in the list that

image text in transcribedwhere are the unit test?

Problem: Find Pairs Given a list of unique integers and a target integer, find all pairs in the list that add up to the target. Example Given a list of integers [1,2,3,4,5] and a target integer 5 , the function should return {(1,4), (2, 3)\} (a set of tuples): find_pairs_naive ([1,2,3,4,5],5) {(1,4),(2,3)} Part 1: Implementation Create a file hw3.py. In this file, you need to write two functions that behave as desribed above: find_pairs_naive() and find_pairs_optimized(). Use test-driven development as you go - write unittests (using the unittest module) in a file TestHw3.py. As always, write your own tests - don't use any of the examples shown in this assignment. - Test the correctness of the two functions: - Test the functions with different inputs and check if the output is correct. - Test the function with edge cases and different inputs to check the correctness of the functions. For example: * test case with empty list test case with target =0 * test case with expected duplicate values as the target. For example if input list is [1,2,3, 4,5] and target is 10, the output should be an empty set set() * test case with target that equals to double number. For example, For example if input list is [1,2,3,4,5] and target is 6 , the output should be {(2,4), (1,5) }. Pair (3,3) should not be included. find_pairs_naive(lst, target) This function should iterate over the entire list using two nested loops to check for pairs that add up to the target. - Input: - lst: a list of integers - target: an integer

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 And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions