Description
Price: ₹399 - ₹338.00
(as of Oct 28, 2024 15:52:11 UTC – Details)
I wanted to compute 80th Term of the Fibonacci series. I wrote the rampant recursive function,
In fib(int N){
return (1==n 2==n)? 1: fib(n-1) + fib(n-2);
}
And waited for the result. I wait… And wait… And wait… <Br> With an 8GB Ram and an Intel br>i5 br>cpu, why is it taking so long? I terminated the process and tried computing the 40th Term. It took about a second. I put a check and was shocked to find that the above recursive function was called 204, 668, 309 times while computing the 40th Term. <Br> More than 200 million times? Is it reporting function calls or scam of some government? <Br> The dynamic programming solution computer 100th Fibonacci Term in less than fraction of a second, with a single function call, taking linear time and constant extra memory. <Br> A recursive solution, usually, neither pass all test cases in a coding competition, nor does it impress the interviewer in an interview of Company like Google, Microsoft, etc. <Br> The most difficult questions asked in competitions and interviews, are from dynamic programming. This book takes dynamic programming head-on. It first explain the concepts with simple examples and then deep dives into complex DP problems.
In fib(int N){
return (1==n 2==n)? 1: fib(n-1) + fib(n-2);
}
And waited for the result. I wait… And wait… And wait… <Br> With an 8GB Ram and an Intel br>i5 br>cpu, why is it taking so long? I terminated the process and tried computing the 40th Term. It took about a second. I put a check and was shocked to find that the above recursive function was called 204, 668, 309 times while computing the 40th Term. <Br> More than 200 million times? Is it reporting function calls or scam of some government? <Br> The dynamic programming solution computer 100th Fibonacci Term in less than fraction of a second, with a single function call, taking linear time and constant extra memory. <Br> A recursive solution, usually, neither pass all test cases in a coding competition, nor does it impress the interviewer in an interview of Company like Google, Microsoft, etc. <Br> The most difficult questions asked in competitions and interviews, are from dynamic programming. This book takes dynamic programming head-on. It first explain the concepts with simple examples and then deep dives into complex DP problems.
Publisher : Notion Press; 1st edition (1 January 2017)
Language : English
Paperback : 142 pages
ISBN-10 : 1946556696
ISBN-13 : 978-1946556691
Item Weight : 200 g
Dimensions : 15.24 x 0.81 x 22.86 cm
Country of Origin : India