Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8613485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:53:18+00:00 2026-06-12T04:53:18+00:00

As I gain an understanding of dynamic programming, I am finding it easier and

  • 0

As I gain an understanding of dynamic programming, I am finding it easier and easier to develop a notion of optimal substructure in a given situation. For example, with finding the optimal ordering to multiply a matrix chain, I understand that (sorry to be verbose; it helps me out) the minimum number of multiplications needed to compute Ai * Ai+1 * … * Aj can be found by finding the split/parenetheses placement point k between i and j that minimizes the sum of the multiplications needed for Ai*…Ak and Ak+1…*Aj, plus the cost that comes with the actual dimensions. In other words, M(i,j) = mink(M(i,k) + M(k+1,j) + di-1dkdj).

Likewise, in finding the longest palindromic substring of a string, the optimal substructure is that the length l[i,j] of a maximum length palindrome between indices i and j and the input array is either 2 + l[i+1, j-1], when the elements at i and j are the same and can thus be added, or otherwise the maximum of l[i+1, j], l[i, j-1] (correct me if I mix anything up…)

But how, in any situation, do I translate this into an algorithm to find the length of an ideal sequence such as the above or even its contents? Do I basically just run loops to tabulate everything, and then essentially ‘choose’ what is needed from the table? With the matrix chain, that seems to be exactly what to do, but for the palindrome, I’m a little confused on how to construct the loops.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:53:20+00:00Added an answer on June 12, 2026 at 4:53 am

    Do I basically just run loops to tabulate everything, and then essentially ‘choose’ what is needed from the table?

    In short, yes. Dynamic programming relies on two things: making the original problem smaller (which is well described in your question) and base cases: those (almost always small) situations where the solution is obvious, and no longer requires dividing the problem into sub-problems. For example, in your matrix multiplication example, once the sub-problem is reduced to 2 matrices, you no longer have a choice: you have to multiply them as is. In your palindrome example, I would choose a base case of a substring of length 1, which is obviously a palindrome.

    Therefore, once you create the memoization array / matrix etc, what you typically do is set the base case values in that array, and let the algorithm run. The end conditions are usually either when you reach the correct point in the array, or when there is nothing left to calculate (at which point you ‘choose’ what you need from the array / matrix etc)

    I hope that’s concrete enough to be useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to gain a basic understanding of what is meant by a Windows
I've been trying to gain a deeper understanding of how compilers generate machine code,
I am a long-time Mac user looking to gain a decent understanding of Windows.
I'm fairly new to Rails and I'm trying to gain a better understanding of
I'm trying to gain deeper understanding of the way CLR works and can't find
To gain a better understanding, I think it would be great to watch every
I'd like to gain a better understanding of escape character sequences in R. I've
I'm experimenting with Xlib to gain a deeper understanding of how Linux GUI programs
I have been downloading a lot of example code to help me gain a
I want to gain a better understanding of how to implement the RAII idiom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.