. Suppose a computer program has been initialized such that the following sets have been stored for use in any algorithm: A = {1, 2, 3, ..., 45} B = {-7, -6, -5, ..., 27} Consider the following algorithm, which represents one part of the whole computer program (comments may occur after the # symbol on any line and are not used in computations): #Part 1: computes A - B and its cardinality AminusB = set() for element in A: # this line runs through every element in A if not(element in B): #A - B is the set of elements that are in A and are not in B AminusB.add(element) # Add to AminusB every element in A if the element is also not in B n = len(AminusB) #len() returns the number of elements in the array print(n) What value is printed as a result of executing this algorithm Answer Q10A. Consider the following algorithm: g1 = 3 g2 = 6 for k > 2: gk = (k-1)·gk-1 - gk-2 What is term g6 of the recursive sequence generated as a result of executing this algorithm? Your Answer: Question 4 options: Answer Q9A. Consider the following algorithm: sum = 0 for j in range(1,12): sum = sum + (6*j - 2) print(sum) What is printed as a result of executing this algorithm?
Q20. Suppose a computer program has been initialized such that the following sets have been stored for use in any
A = {1, 2, 3, ..., 45}
B = {-7, -6, -5, ..., 27}
Consider the following algorithm, which represents one part of the whole computer program (comments may occur after the # symbol on any line and are not used in computations):
#Part 1: computes A - B and its cardinality
AminusB = set()
for element in A: # this line runs through every element in A
if not(element in B): #A - B is the set of elements that are in A and are not in B
AminusB.add(element) # Add to AminusB every element in A if the element is also not in B
n = len(AminusB) #len() returns the number of elements in the array
print(n)
What value is printed as a result of executing this algorithm
|
Answer |
Q10A. Consider the following algorithm:
g1 = 3
g2 = 6
for k > 2:
gk = (k-1)·gk-1 - gk-2
What is term g6 of the recursive sequence generated as a result of executing this algorithm?
|
Answer |
Q9A. Consider the following algorithm:
sum = 0
for j in range(1,12):
sum = sum + (6*j - 2)
print(sum)
What is printed as a result of executing this algorithm?
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images