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

  • Home
  • SEARCH
  • 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 6768613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:05:43+00:00 2026-05-26T15:05:43+00:00

I found this while looking up problems on dynamic programming. You are given an

  • 0

I found this while looking up problems on dynamic programming.
You are given an unparanthesized expression of the form V0 O0 V1 O1 …. Vn-1

We have to put brackets at places which maximizes the value of the entire expression.

V’s are the operands and O’s are the operators.
In the first version of problem operators can be * and + and operands are positive.
Second version of problem is completely general.

For the first version i came up with DP solution .

Solution –
A[] = operands array
B[] – operators array
T(A[i,j]) – max value of expression
T(A[0,n-1]) = max over all i {(T(A[0,i]) Oi T(A[i+1,n-1]))}

The boundary cases are trivial (when i = j).
I need help with the following –
Analyze the running time of this algorithm. And if there exists a better one.

  • 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-05-26T15:05:44+00:00Added an answer on May 26, 2026 at 3:05 pm

    It is easier to analyze calculation of A[i,j] elements from shorter ranges to longer ranges. Algorithm for that looks like:

    # Initialization of single values
    for i in 0, ..., n-1:
      A[i,i] = V[i]
    
    # Iterate through number of operation
    for d in 1, ..., n-1:
      # Range start
      for i in 0, ..., n-1-d:
        j = i + d
        A[i,j] = max( A[i,x] O_x A[x+1,j] for x in i, ..., j-1)
    
    print 'Result', A[0,n-1]
    

    Since A[] can be implemented with constant time access (array) than algorithm is O(n^3).

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

Sidebar

Related Questions

I found this programming problem while looking at a job posting on SO. I
I've been looking for a solution to this for a while now, have found
I've been looking at this for a while. I've found plenty of posts and
I am a beginner in C. While reading git's source code, I found this
This took me a while to figure out and I found the answer on
While trying to answer this question I found that the code int* p =
I've been struggling with this issue for a little while now. Found several posts
While reading SICP I came across logic programming chapter 4.4. Then I started looking
I've been looking this over for a while now and can't seem to pinpoint
While looking on some legacy code, I found a rather unusual construction (for me

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.