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 6896233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:00:35+00:00 2026-05-27T07:00:35+00:00

I am following tardos book to learn dynamic programming. I have a doubt in

  • 0

I am following tardos book to learn dynamic programming. I have a doubt in the solution construction part of weighted interval scheduling problem.
It is suggested that instead of using another array to store the solution, we should use the same cost array in this way :

Find-Solution(j)
 if  j = 0 then 
   output nothing
 else
   If Vj + M[p(j)] >= M[j-1] then
    output j together with the result of find-solution(p(j))
 else
   output find-solution(j-1)
 endif

My problem is that to find p(j) it should take O(n) time, and we can make these recursive calls O(n) time making this algorithm O(n^2). But in book it is claimed that this is O(n).
Also we are doing pretty much the same calculation we did to find the cost array m again. is there a way to eliminate this. If I want to use an array to store solution, what should I store in that ?

  • 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-27T07:00:36+00:00Added an answer on May 27, 2026 at 7:00 am

    I think their analysis is assuming that you have precomputed all values of p and in that case the runtime of the method is indeed O(n). Computing the values of p though will take O(n log n).

    See how to compute p here: http://www.cs.cornell.edu/courses/cs4820/2010su/handouts/computation-of-p-j.pdf

    To see similar analysis about the algorithm: http://www.cs.uiuc.edu/class/fa08/cs473/Lectures/lecture12.pdf. There it also claims that the computation takes O(n). But you will see in the end his analysis of the total running time including computing p is O(n log n).

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

Sidebar

Related Questions

following problem: I have a simple paragraph with a lot of text where I
following extjs3 problem: i have an json store: dbStore = new Ext.data.JsonStore({ url: '/?[action]=getFormData',
Following is my javascript code. The problem is when I call the send() function
Following on from another question I have asked I have created a new class
Following are the two approaches: constructor with all the class properties Pros: I have
Following the way Rob does it, I have the classes that are generated by
Following suggestions on this site, I have adopted SimpleXML from org.simpleframework.xml. I use this
Following is the scenario: I have a remote Mercurial repository at ssh://remotehost//dir/repo and I
Following this post and the other posts that it links to, I have successfully
Following on from a previous question . Lets say I have two checkboxes on

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.