subject

Below we've attempted to write a recursive formula that will calculate the nth triangular number. 1 def tri(n): return n + tri(n - 1) what will be the current result of using this function? it will correctly calculate the nth triangular number oit will instead calculate the n 1th triangular number. it will instead calculate the n +1th triangular number. o it will cause a runtimeerror due to infinite recursion. it will cause a nameerror due to attempting to call try) from within try problem 5.2.2, part 2 of 3 1.0/1.0 point (graded) why does the issue or error in the problem above occur? o no issue occurs; the function correctly calculates the nth triangular number. o the recursive function has no base case, so it never stops calling copies of itself. o the recursive function has no base case, so it never calls a copy of itself. othe recursive function incorrectly calls itself with n -1 as an argument instead of n o the recursive function incorrectly calls itself with n 1 as an argument instead of n1. othe variable n - 1 is not defined when referenced on line 2 which of the following revisions to the function tri) would fix the observed issues? no revision necessary; the original function works. 1| def tri(n): if n == 1: return 1 4else: 5 l return n tri (n-1) 1| def tri(n): 2 if n return n +tri(n-1) 4lse: return 1 1| def tri(n): if n > 1 return 1 4lse return n + tri(n-1) 1| def tri(n): 21f n> 1: return n tri(n-1) 4 else: return1

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:50
Consider a slotted aloha system, where the time slot equals the fixed duration of each packet. assume that there are 4 stations a,b,c,d sharing the medium. (a) stations a,b,c,d receive one packet each from higher layers at times 1.3, 1.5, 2.6,5.7 respectively. show which transmissions take place when, according to the slottedaloha protocol; describe all transmissions until all four packets have been successful.when needed, each station has access to the following sequence of random number, provided by a random number generator and drawn uniformly between 0 and 1: (1) station a draws numbers: 0.31, 0.27, 0.78, 0.9, 0.9, 0.11, 0. (2) station b draws numbers: 0.45, 0.28, 0.11, 0.83, 0.37, 0.22, 0. (3)station c draws numbers: 0.1, 0.2, 0.3, 0.4, 0. (4) station d draws numbers: 0.36, 0.77, 0.9, 0.1, 0.1, 0.1, 0.1, 0. (b) in slotted aloha, a station transmits in each time slot with a given probability. what probabilities would you assign to each of the four stations so as to: (i) maximize the efficiency of the protocol? (ii) maximize fairness among the four stations? (c) will the efficiency increase or decrease if we modify slotted aloha as follows: (i) get rid of slots and allow stations to transmit immediately? (ii) implement carrier sensing? (iii) implement collision detection? (iv) implement collision avoidance?
Answers: 3
question
Computers and Technology, 22.06.2019 20:10
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
question
Computers and Technology, 23.06.2019 01:00
Write the command that can be used to answer the following questions. (hint: try each out on the system to check your results.) a. find all files on the system that have the word test" as part of their filename. b. search the path variable for the pathname to the awk command. c. find all files in the /usr directory and subdirectories that are larger than 50 kilobytes in size. d. find all files in the /usr directory and subdirectories that are less than 70 kilobytes in size. e. find all files in the / directory and subdirectories that are symbolic links. f. find all files in the /var directory and subdirectories that were accessed less than 60 minutes ago. g. find all files in the /var directory and subdirectories that were accessed less than six days ago. h. find all files in the /home directory and subdirectories that are empty. i. find all files in the /etc directory and subdirectories that are owned by the group bin."
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
What are loans to a company or government for a set amount of time
Answers: 1
You know the right answer?
Below we've attempted to write a recursive formula that will calculate the nth triangular number. 1...
Questions
question
History, 08.03.2021 20:10
question
Geography, 08.03.2021 20:10
question
English, 08.03.2021 20:10
Questions on the website: 13722362