ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!

  • google app store apple app store
  • тЬЦ

      Question

      Consider the following Python code for calculating

      Fibonacci numbers using memoization: ┬а ┬а memo = {} ┬а ┬а def fib_memo(n): ┬а ┬а ┬а ┬а if n ┬а ┬а ┬а ┬а ┬а ┬а return n ┬а ┬а ┬а ┬а if n in memo: ┬а ┬а ┬а ┬а ┬а ┬а return memo[n] ┬а ┬а ┬а ┬а result = fib_memo(n-1) + fib_memo(n-2) ┬а ┬а ┬а ┬а memo[n] = result ┬а ┬а ┬а ┬а return result ┬а ┬а # Call: fib_memo(5) ┬а ┬а What is the sequence of values stored in memo after fib_memo(5) completes?
      A {2: 1, 3: 2, 4: 3, 5: 5} Correct Answer Incorrect Answer
      B {1: 1, 2: 1, 3: 2, 4: 3, 5: 5} Correct Answer Incorrect Answer
      C {0: 0, 1: 1, 2: 1, 3: 2, 4: 3} Correct Answer Incorrect Answer
      D {5: 5} Correct Answer Incorrect Answer
      E {} (empty) Correct Answer Incorrect Answer

      Solution

      The correct answer is A

      Practice Next
      More IT Operating System Questions
      ask-question