Question: Question 1 (3 points) Q9. Consider the following algorithm: sum = 0 For j starting at 1 and ending with 13 sum = sum +

Question 1 (3 points) Q9. Consider the following
Question 1 (3 points) Q9. Consider the following algorithm: sum = 0 For j starting at 1 and ending with 13 sum = sum + (5*j + 2) print(sum) What is printed as a result of executing this algorithm? Your Answer: Answer Question 2 (3 points) Q10. Consider the following algorithm: 81 = 7 82 = 8 For k starting at 3 and ending with 8 8k = (k-1)-gk-1 + 8k-2 What is the last term, g8, of the recursive sequence generated as a result of executing this algorithm? Your Answer: Answer Question 3 (3 points) Q20. Suppose a computer program has been initialized such that the following sets have been stored for use in any algorithm: A = {1, 2, 3, ..., 50} B = {-7, -6, -5, ..., 29} 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? Your Answer: Answer Question 4 (3 points) Q10A. Consider the following algorithm 81 = 4 82 = 9 for k > 2: Sk = (k-1)-gk-1 - 8k-2 What is term go of the recursive sequence generated as a result of executing this algorithm? Your Answer: Answer Question 5 (3 points) Q9A. Consider the following algorithm sum = 0 for j in range(1,11): sum = sum + (6*j - 5) print(sum) What is printed as a result of executing this algorithm? Your Answer:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!