Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the function interface documentation (the code is not shown because we don't need it) def check_row(row): Purpose: Checks whether the given list contains all

image text in transcribed
image text in transcribed
image text in transcribed
Consider the function interface documentation (the code is not shown because we don't need it) def check_row(row): Purpose: Checks whether the given list contains all the integers 1, ..., N, where N is the length of the list. Pre-Condition(s): row: a list of numbers Post-Condition(s): None Return(s): True if the list has all the numbers 1,...,N False otherwise Now consider the following test case: inputs = [1, 2, 31 expected - True reason - "Valid row 1" result - check_row(inputs) if result !- expected: print("Error in (): expected () but obtained () -- ()'.format(test_item, expected, result, reason)) Which of the following statements is true for this test case? Select one: O a. This is a black-box test case. O b. It could be either white-box or black box. O c. This is a white-box test case. Consider the function selection_sort that we looked at in lecture. def selection_sort(unsorted): Purpose: To order the values in increasing order. Pre-conditions: param unsorted: a list of numbers Post-conditions: All values are removed from unsorted. Return: a list of all the values from unsorted, but in increasing order. sorted - list) while len(unsorted) > 0: out - min(unsorted) unsorted.remove(out) sorted.append(out) return sorted We saw several test cases that focussed on the return value, but we did not check the post-conditions, Which of the following test cases checks the post-condition for selection sort? Select one: a. data_1 - [0,1,4] expected - [] reason = "check post-conditions for a short list" # call the operation selection(data_1) result - unsorted if result !- expected: print('Error in {}: expected () but obtained () -- ()'.format(test_item, expected, result, reason)) O b. data_1 [0,1,4) expected - [0, 1, 4) reason = "check post-conditions for a short list" # call the operation result - selection(data_1) if result 1 - expected: print('Error in (): expected () but obtained () -- ()'.format(test_item, expected, result, reason)) Oc. data_1 - [0,1,4] expected - [] reason = "check post-conditions for a short list" # call the operation selection(data_1) result = data_1 if result 1 - expected: print('Error in (): expected (} but obtained {} {}'.format(test_item, expected, result, reason))

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

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago