Need help with two parts of this one question for Discrete Mathematics; here is
ID: 3887890 • Letter: N
Question
Need help with two parts of this one question for Discrete Mathematics; here is the problem below:
Both programs are correct and produce the same output, but not equal with equal computational efficiency. Alex's program finishes practically instantaneously, while Casey's program slows down noticeably when n reaches about 20 to 30 and keeps getting slower with each passing n .
d) Find a closed form representation for an
e) How many arithmetic operations (counting multiplications and additions) must Alex's program perform? Give the exact number and a brief explanation.
Week 5-201 7FalIA-X-M × / D MAT 243 Online Week 5 Secure https://myasucourses asu.edu/bbcswebdav/pid 16327146 dt content-rid-1060453051/courses/201 7FallAX-MAT243-78707/Week%205%20Homework%2839629.pdf 3. Two students, Alex and Casey, wrote Python programs to compute and print the terms a2 to a100 of the same recursively defined sequence {an}. Alex's program Casey s program def a (n): n=2 if n= 0: return 0 elif n=-1: return 1 while nExplanation / Answer
Your question d is incomplete to be answered. Clearly, state it in the comments for help. Sample closed form representation.
e) The number of additions in Alex's program is 2 which is done at the lines
new = 2 * a + b
n = n + 1
The number of multiplications in Alex's program is 1 which is done at the line
new = 2 * a + b
So for a single iteration of while loop total three operations are performed and for n iterations n * 3 times the operations are performed. The condition for the while loop is n <= 100 where n = 2. so the no of iterations are 99.
So the total no of times the arithmetic operations (counting multiplications and additions) must Alex's program perform is 99 * 3 = 297.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.