Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 (3 points) Q9. Consider the following algorithm: sum = 0 for j in range(1,10): sum = sum + (9*j + 4) print(sum) What

image text in transcribedimage text in transcribedimage text in transcribed
Question 1 (3 points) Q9. Consider the following algorithm: sum = 0 for j in range(1,10): sum = sum + (9*j + 4) 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 = 3 82 = 8 for k in range(3,8): 8k = (k-1).8k-1 + 8k-2 What is the last term, gg, of the recursive sequence generated as a result of executing this algorithm? Your Answer: AnswerQuestion 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, ..., 40} B = {-7, 6, -5, ..., 28} 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: computesA - B and its cardinality AminusB = set() for element in A: # this line runs through every element in A if not(e|ement 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) #leni) 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: S1=5 82=3 fork>2: gk = (k-1)gk-1 ' gk-2 What is term g6 01' 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] in range(1,13}: sum = sum + (4*j - 3) print(sum) What is printed as a result of executing this algorithm? Your

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

Probability Theory A Concise Course

Authors: Y A Rozanov

1st Edition

0486321142, 9780486321141

More Books

Students also viewed these Mathematics questions

Question

what are the six steps to effective financial statement analysis

Answered: 1 week ago

Question

Be relaxed at the hips

Answered: 1 week ago