Dynamic Programming for Coding Interviews
eBook - ePub

Dynamic Programming for Coding Interviews

A Bottom-Up approach to problem solving

  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Dynamic Programming for Coding Interviews

A Bottom-Up approach to problem solving

About this book

I wanted to compute 80th term of the Fibonacci series. I wrote the rampant recursive function, int 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…With an 8GB RAM and an Intel i5 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. More than 200 million times? Is it reporting function calls or scam of some government?The Dynamic Programming solution computes 100th Fibonacci term in less than fraction of a second, with a single function call, taking linear time and constant extra memory.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. 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.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Dynamic Programming for Coding Interviews by Meenakshi,Kamal Rawat in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Algorithms. We have over one million books available in our catalogue for you to explore.

Table of contents

  1. Title
  2. Copyright
  3. Dedication
  4. Preface
  5. Acknowledgments
  6. How to Read this Book
  7. 1 Recursion
  8. 2 How it Looks in Memory
  9. 3 Optimal Substructure
  10. 4 Overlapping Subproblems
  11. 5 Memoization
  12. 6 Dynamic Programming
  13. 7 Top-Down v/s Bottom-Up
  14. 8 Strategy for DP Question
  15. 9 Practice Questions
  16. About the Author