Introduction

Dynamic programming can be thought of as a way of breaking a complex problem into sub-problems, solving each of these sub-problems once, and saving the solutions for later use. As we’ll see later in this article, this approach offers efficiency and modularity benefits over other approaches, which we’ll explore shortly.


Dynamic Programming Techniques

When we talk about dynamic programming, we must also discuss the following techniques:

  • Memoization: Not to be confused with MemorizationMemoization is a technique for improving the performance of a recursive function/algorithm. In other words, it offers an optimization to speed up programs by storing the solutions of expensive function calls and returning the cached solution when the same inputs are fed to the program again.
  • Tabulation: Also known as the Bottom-Up technique, this is another optimization technique used in dynamic rogramming. As you might guess, this technique takes a tabular approach by first filling up a table, then solves the original problem based on the solutions filled in the table.

In this article, we’ll only be looking at memoization, not tabulation.

#golang #algorithms #software-development #go

Dynamic Programming in Golang
14.70 GEEK