Popular Posts

이은한. Powered by Blogger.

2022년 2월 18일 금요일

what is Dynamic Programming


Dynamic Programming

Definition

One of problem solving technique

Split huge problem into many simple subproblems and reduce steps of subproblems.
Then get solution by addition of all subproblems.

Example

if you calculate 21+22+23+24+252^1+2^2+2^3+2^4+2^5,

You can find answer by calculating
2+(22)+(222)+(2222)+(22222)2+(2*2)+(2*2*2)+(2*2*2*2)+(2*2*2*2*2)

However, there is another way in computer.
21=2=22^1=2=2
22=22=2122^2=2*2=2^1*2
23=222=2222^3=2*2*2=2^2*2
24=2222=2322^4=2*2*2*2=2^3*2
25=22222=2422^5=2*2*2*2*2=2^4*2

You can skip some of parts that you already calculated. When you calculate the 252^5, you done have to calculate 242^4 if that number 242^4 is already calculated.

0 개의 댓글:

댓글 쓰기