CSE 2050 Exam 2 - Recursion, Sorting, and Hashing with Correct Verified Answers| Latest 2024
emoization - ANSWER Write the recursive function top-down. Alter the function to check if we've already calculated the value. If so, use the pre-calculated value, If not, do the recursive call. Fib - Memo - ANSWER def fib(n, fib_cache): if n in fib_cache: return fib_cache[n] fib_cache[n] = fib(n-1, fib_cache) + fib(n-2, fib_cache)
Written for
- Institution
- CSE 2050
- Course
- CSE 2050
Document information
- Uploaded on
- July 1, 2024
- Number of pages
- 14
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
cse 2050 exam 2
-
recursion sorting and hashing
Content preview
Also available in package deal