times scratch larger examples many values code fib code ' 'subproblems'' recalculated leading exponential time algorithm suppose simple map object ''m'' maps value code fib code already calculated result modify function use update resulting function requires ''n'' time instead exponential time requires ''n'' space '''var''' '''''map''''' '''function''' fib n '''if ''key''''' n '''is ''map''''' n fib n fib n '' 'return''' n
Applied science Transportation Operations research Dynamic programming