Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi there! Read carefully please****: The first 2 pictures is the main question and the last 2 pictures are a3q1_provided.py file. Please give me

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Hi there! Read carefully please****:

The first 2 pictures is the main question and the last 2 pictures are " a3q1_provided.py" file.

Please give me the full hand written answer of this question and a picture of your code. And make sure to answer all of its parts.

Please Solve it only if you're sure that your answer is 100% correct otherwise let any other person to solve it.

I need the Correct answer please otherwise I'll give dislike and report it to the Chegg authorities. Sorry for these words but I'm tired of getting lots of wrong answers lately.

Please answer it as soon as possible with clear hand writting and and picture of your code. Thank you so much for your time and effort! Will give Thumbs-up if everything is Alright!

One probtem with this implementation is that it modifies the original list (line 6). Unless we know for sure that a list will never be needed in the future. removing all contents is a bit drastic. To address this problem. we can change the code so that a copy of the original list is made first Since we make the copy. we can say fer sure that the copy will never be needed in the future and so removing all its contents is absolutely fine. The file a3q1.py is available on Canvas, and it contains a function called selection sort () which is very similar to the above code: Also in the file there are 5 different functions whose intended behaviour is to copy a list. Your job in this question is to determine which, if any. of these functions does the job right. Note: There is a Python list method called copy (). which we are not using on purpose. We need to understand references, and we must not side-step the issue. Task For each of the 5 copy () functions in the file a 3q1. py. do the following Detemine if the function makes a copy of the list Hint some do not! - Determine if the function is suitable for use in selection sort (). Hint some are not! Do not change the function selection_sort() except to make use of one of the versions of the copy() function on line 11. Do not change the code for any of the copy () functions. You will only necd one or two lines of code to use the different functions, but exactly how many you need is part of the problem. Note: Some of the doc-strings may be inaccurate or wrong This is part of the problem. In fact. it's quite common for poor programmers to fix bugs and redesign functions, without correcting the documentation! What to Hand in Your answers to the above questions in a text file called a3q1.txt. (PDF. rtf docx or doc are acceptable) You might use the following format: The above exampte does not necessarily reftect the right answers: Be sure to include your name. NSID. student number, section number, and Laboratory section at the top of all documents Evaluation Each of the copy functions is worth 2 marks Your answers to both questions have to be correct to get the marks. Copies the given list of data. Preconditions: :param data: a list :param copy: an empty list Post-conditions: copy has the same contents as data :return: None "11" copy = list () for d in data: copy. append(d) return None def copy5(data, copy): copies values from data to the empty list copy Preconditions: :param data: a list Post-conditions: copy has the same contents as data Return: None for d in data: copy = copy +[d] return None def selection_sort(unsorted): Returns a list with the same values as unsorted, but reorganized to be in increasing order. :param unsorted: a list of comparable data values ineturn: a sorted list of the data values result =list() acopy = list () copy4(unsorted, acopy) while len(acopy) >0: out =min (acopy) acopy, remove(out) result. append(out) return result

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

Explain how psychologists use traits to describe personality.

Answered: 1 week ago

Question

Compose the six common types of social business messages.

Answered: 1 week ago

Question

Describe positive and neutral messages.

Answered: 1 week ago