Question
Need help with these question, These are for a Discrete Mathematics question and sub-topics are Sets, Sequences and Series question two seem to be higher
Need help with these question, These are for a Discrete Mathematics question and sub-topics are Sets, Sequences and Series question two seem to be higher possible in the 60k range mostly.
Here is quick guide on why I keep failing these answers, the guide below is from another set of questions so they don't matter to bottom question it just show where the errors I have
Here's the errors:
Q1:
j=1:
sum = 0+ (7 * 1)+ 6 = 13. Sum starts at 0, so it is 0+ for that one
j=2:
sum = 13+ (7 * 2)+ 6 = 13+ 14+ 6 = 33. Note the algorithm says sum+ 7j+6, not j+ 7j+6. You did it as j instead of sum.
Also if you do it that way the value at the end is the answer, no need to add them. The sum at the start of the algorithm is keeping the sum current so adding together not needed.
Q2:
The sequence is not arithmeticso you can't use that formula. Its not geometric either, its none of the above. Its a recursive sequence so you have to find g3 with the starting terms, use that to get g4, then g5 then g6 then g7 and so on. There is no other valid way to find it. I have an example on Q4 below to show more on this.
Q3: A - B is the terms 23 to 40, so there are: 40 - 23+ 1 = 18 terms present.
Q4:
Also not arithmetic or geometric so can't use that formula. The only way to solve it that is valid is this:
We know g1 = 6 and g2 = 6.
g3 = (3-1) * g2 - g1, so that becomes (3-1) * 6 - 6 = 2 * 6 - 6 = 6
g4 = (4-1)*g3 - g2 = 3 * 6 - 6 =12
Next find g5, g6, and so on.
Q5:
Same error as Q1. Sum is recursive so must be updated each step, and sum starts at 0. No adding all of then together if you work it that way too, the answer at the end is it.
Here the question I need help with
Question 1
Q9. consider the following algorithm:
sum = 0
for j in range(1,14): sum = sum + (7*j + 7) print(sum)
What is printed as a result of executing this algorithm?
Your Answer:
Question 1 options:
Answer |
Question 2
Q10. Consider the following algorithm:
g1 = 4
g2 = 2
for k in range(3,8):
gk = (k-1)gk-1 + gk-2
What is the last term, g8, of the recursive sequence generated as a result of executing this algorithm?
Your Answer:
Question 2 options:
Answer |
Question 3
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, ..., 49} B = {-7, -6, -5, ..., 30}
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:
Question 3 options:
Answer |
Question 4
Q10A. Consider the following algorithm:
g1 = 9
g2 = 4
for k > 2:
gk = (k-1)gk-1 - gk-2
What is term g6of the recursive sequence generated as a result of executing this algorithm?
Your Answer:
Question 4 options:
Answer |
Question 5
Q9A. Consider the following algorithm:
sum = 0
for j in range(1,15): sum = sum + (7*j - 8) print(sum)
What is printed as a result of executing this algorithm?
Your Answer:
Question 5 options:
Answer |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started