Articles
Windows FAQ
"Office 15 Click-to-Run Licensing Component" Installed Program o...
"Office 15 Click-to-Run Localization Component" Installed Progra...
"Pulse Secure" Installed Program on Windows 7 - What is the inst...
Visible Installed Programs using Windows Installer on Windows 7 ...
"Adobe Acrobat Reader DC MUI" Installed Program on Windows 7 - W...
Who's Online
9 user(s) are online (4 user(s) are browsing Forum)

Members: 0
Guests: 9

more...

Browsing this Thread:   1 Anonymous Users





Algorithms for coding interviews - dynamic programming
Home away from home
Joined:
2007/11/11 12:07
Group:
Registered Users
Posts: 329
Level : 16; EXP : 94
HP : 0 / 398
MP : 109 / 11113
Offline
Algorithms for coding interviews - dynamic programming

Dynamic programming is a technique for solving problems with the following properties:

 An instance is solved using the solutions for smaller instances.
 The solution for a smaller instance might be needed multiple times.
 The solutions to smaller instances are stored in a table, so that each smaller instance is solved
only once.
 Additional space is used to save time.
The problem of climbing steps perfectly fit those 4 properties. Therefore, it can be solve by using
dynamic programming.
public s t a t i c int [ ] A = new int [ 1 0 0 ] ;
public s t a t i c int f3 ( int n) {
i f (n <= 2)
A[n]= n ;
i f (A[n] > 0)
return A[n ] ;
else
A[n] = f3 (n􀀀1) + f3 (n􀀀2) ; / / s t o r e r e s u l t s s o only c a l c u l a t e onc e !
return A[n ] ;
}

Posted on: 4/3 15:49
Transfer the post to other applications Transfer






You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Copyright (c) 2015 FYIcenter.com
Search
Main Menu
Login
Username:

Password:

Remember me



Lost Password?

Register now!