Week 6 - Quiz (Programming, Datastructures and Algorithms using Python) (NPTEL 2022 - CS26)
Get link
Facebook
X
Pinterest
Email
Other Apps
Supposeuandvboth denote sets in Python. Under what condition can we guarantee thatu-(v-u) == u?
Feedback:
v-u has no elements from u, so u-(v-u) removes nothing from u and is hence always equal to u.
Accepted Answers: D
2.5 points
Suppose u and v both denote sets in Python. and u|v != u^v. What can we conclude about u and v?
Feedback:
If the two sets were disjoint, we would have u|v == u^v. Since the two expressoins are not equal, it must be that the sets overlap.
Accepted Answers: D
2.5 points
Which of the following does not correspond to a min-heap on the list of values [19,97,83,45,72,55,31,28,31,29].
Feedback:
In [19, 28, 29, 31, 45, 83, 97, 55, 72, 31], value 45 has left child 31.
Accepted Answers: D
2.5 points
Consider the min-heap [19, 28, 31, 31, 29, 83, 55, 97, 45, 72]. Suppose we apply the operation delete_min() to this min-heap. The resulting min-heap is:
All questions carry equal weightage. All Python code is assumed to be executed using Python3. You may submit as many times as you like within the deadline. Your final submission will be graded. Note : If the question asks about a value of type string , remember to enclose your answer in single or double quotes. If the question asks about a value of type list , remember to enclose your answer in square brackets and use commas to separate list items. Consider the following Python function. def mystery(l,v): if len(l) == 0: return (v) else: return (mystery(l[:-1],l[-1]+v)) What does mystery([22,14,19,65,82,55],1) return? Accepted Answers: (Type: Numeric) 258 2.5 points What is the value of triples after the following assignment? triples = [ (x,y,z) for x in range(2,4) for y in range(2,5) for z in range(5,7) if 2*x*y > 3*z ] Feedback: triples = [] for x in range(2,4): # x = 2,3 for y in range(2,5): # y = 2,3,4 for z in range(...
One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.) x = [1,"abcd",2,"efgh",[3,4]] # Statement 1 y = x[0:6] # Statement 2 z = x # Statement 3 w = y # Statement 4 x[1] = x[1][0:3] + 'd' # Statement 5 y[2] = 4 # Statement 6 z[1][1:3] = 'yzw' # Statement 7 z[0] = 0 # Statement 8 w[4][0] = 1000 # Statement 9 a = (x[4][1] == 4) # Statement 10 Accepted Answers: 7 (Type: Numeric) 7 2.5 points 2.5 points Consider the following lines of Python code. x = [423,'b',37,'f'] u = x[1:] y = u w = x u = u[0:] u[1] = 53 x[2] = 47 After these execute, which of the following is correct? x[2] == 47, y[1] == 37, w[2] == 47, u[1] == 53 x[2] == 47, y[1] == 53, w[2] == 47, u[1] == 53 x[2] == 47, y[1] == 37, w[2] == 37, u[1] ==...
Comments
Post a Comment