From e9975d95acfbcd743d5f64183d710fff217da302 Mon Sep 17 00:00:00 2001 From: mostafa arshadi <61285975+mosishon@users.noreply.github.com> Date: Thu, 7 Mar 2024 00:58:56 +0330 Subject: [PATCH] Update BottomUpRodCut.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit اگر شمارنده حلقه اول (l) از شماره ۲ شروع بشه، نیازه که قبل از حلقه r[1] رو پر کنیم در غیر اینصورت چون مقدار پیشفرض ۰ قرار گرفته. هزینه r[1] رو صفر در نظر میگیره --- src/dynamicProgarmming/rodcut/BottomUpRodCut.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dynamicProgarmming/rodcut/BottomUpRodCut.java b/src/dynamicProgarmming/rodcut/BottomUpRodCut.java index e708128..6b61e5d 100644 --- a/src/dynamicProgarmming/rodcut/BottomUpRodCut.java +++ b/src/dynamicProgarmming/rodcut/BottomUpRodCut.java @@ -9,7 +9,7 @@ public int bottomUpRodCut(int p[], int n) { if (n <= 1) { r[n] = p[n]; } - + r[1] = p[1]; for (int l = 2; l <= n; l++) { int max = -1; for (int k = 1; k <= l; k++) {