Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

link to the files mentioned in the text: https://drive.google.com/file/d/1V6tn-xURhNxc-yZdEdiBDiEThWPuWxNC/view?usp=sharing fthe closest values If you can. try to do this without testing the same pair of

link to the files mentioned in the text: https://drive.google.com/file/d/1V6tn-xURhNxc-yZdEdiBDiEThWPuWxNC/view?usp=sharing

image text in transcribedimage text in transcribedimage text in transcribed
\fthe closest values If you can. try to do this without testing the same pair of values more than once. To illustrate its usage. assuming we've assigned L1 from above, the node {1.1) - closeat1(L1) print{1, 3) should output 5.4 4.3 Thinkhmdahoutthecasesyoushmddusetotestthatyomoodeisoorrect. Thengenerate examples ofthese maesinthe ments for closestl and run the testingmdeon them; Fixsnymistakes. Also,oonsiderwritingtestcssestocheckthatyoudonotchangethelist. Theseuswillbeenmeuseilifyaulatertorgetthatyouareootsuppmedtochangethe list when you oremodifying the code. To complete Checkpoint 1 Include the followiJJg in your lab notebook: [a] your node and [hlyourtest cases.and{c] thermuitsofrunniogthetestoodeonyourmodule. In addition, be properEd to explain why your tests are reasonably mmpiew, and he propared to demonstrate what happens when your tests foil during the lab period. You might he ashEd to generate new test cases. Checkpoint 2: Solution Based on Sorting Write a function called o1oaast2 that takes as its only argument 8. list of oats (or ints] and returns s. tuple containing the two closest values. Again, when there are less than two values in the list. you should return a tuple {Hons . None}. This function should not change the list. It should. lsmever. make a comr of the list, sort the copy. and then, in ssingle pass through the sorted list. decide which are the two closest values. You might have to think a bit about why this idea should work. Once again. think through the test cases you will need. Then. generate test cases and use them to ensure your function is correct. To complete Checkpoint 2 Put the following in your lab notebook: {a} your code and {h} your test cases. and {c} the results of running the test code on your module. During the lab period,be prepared to explain why your tests are reasonably complete. and be prepared to demonstrate what happens when your tests fail. You might be asked to generate new test cases. Checkpoint 3: Comparative Evaluation In this checkpoint you will evaluate the result in two ways. First, following through what we did in ioctures 2|] anti many other previous lectures. try to think about how many comparisons the rst function (checkl) nude? If the length ofthe list is N, what is {roughly} the niunher of comparisons as a function of N? \f

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions