Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BottomUpRodCut.java #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mosishon
Copy link

@mosishon mosishon commented Mar 6, 2024

اگر شمارنده حلقه اول (l) از شماره 2 شروع بشه، نیازه که قبل از حلقه r[1] رو پر کنیم
در غیر اینصورت چون مقدار پیشفرض 0 قرار گرفته. هزینه r[1] رو صفر در نظر میگیره.
پس مقدار خونه r[1] رو دستی از جدول p میخونیم و قبل از حلقه پر میکنیم

اگر شمارنده حلقه اول (l) از شماره ۲ شروع بشه، نیازه که  قبل از حلقه
r[1] رو پر کنیم 
در غیر اینصورت چون مقدار پیشفرض ۰ قرار گرفته. هزینه r[1] رو صفر در نظر میگیره
@RezaAmirzadehFard
Copy link
Owner

RezaAmirzadehFard commented Mar 8, 2024

I appreciate your correct idea, but if you look more carefully at the previous if-statement, this assignment has been applied.
If i want to explain in more detail, the first if-statment inside bottomUpRodcut function (method 1):

if (n <= 1) {
    r[n] = p[n];
}

checks if n is equal to zero or one then assign corresponding element to these indices in p-array ( price array ) to r-array. In other word, if n = 0 then r[0] = p[0] or if n = 1 then r[1] = p[1].

*And it's correct for rod with length of one that have price 1. otherwise you'r correct.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants