Is each of the following True or False Any program that can be written using onl
ID: 3803049 • Letter: I
Question
Is each of the following True or False Any program that can be written using only function definitions and calls, the basic arithmetic operators, assignment, and conditionals will run in constant time. Newton's method will always converge on a correct root of a function. In Python, dictionaries are immutable. The value of *math.sqrt (2.0)*math.sqrt (2.0) == 2.0' is True. One should always avoid iteration when a recursive solution is possible. Typically, the use of functions in a program reduces the total number of lines of code. In Python, retrieving the value associated with a dictionary key takes roughly constant time.Explanation / Answer
(1) False.
Reason:--> due to the potential for indefinite recursion.
(2) False.
Reason:-->Newton's method may not converge if started too far away from a root.
(3) False.
Reason:-->Dictionaries are mutable, meaning you can change their content without changing their identity.
(4)It will return false.
(5) No, iteration is better than recursion.
Reason:-->You will actually get an error ( RuntimeError: maximum recursion depth exceeded ) indicating that you exceeded maximum recursion depth if your function recurses too far.
Many algorithms are written considering iteration.
(6) yes, when you use functions, If you want call a function n times, you don't need to write again and again, you just need to call it.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.