Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code that I have does not seem to work. I'm pretty sure I messed up in the pseudocode and I'm suppose to follow the

The code that I have does not seem to work. I'm pretty sure I messed up in the pseudocode and I'm suppose to follow the pseudocode. The original skeleton code is below and also the pseudocode. The links below are the psudocode just in case the picture does not appear. Just in case.

https://imgur.com/LqYNM64

image text in transcribed

https://imgur.com/sDxsYMV

image text in transcribed

https://imgur.com/aDqGDrc

image text in transcribed

https://imgur.comF1Py4M

image text in transcribed

package dp;

public class RodCut {

int n;

int[] p;

int[] r;

int[] s;

public RodCut () {

n = 10;

p = new int[11];

p[0] = 0;

p[1] = 1;

p[2] = 5;

p[3] = 8;

p[4] = 9;

p[5] = 10;

p[6] = 17;

p[7] = 17;

p[8] = 20;

p[9] = 24;

p[10] = 30;

}

public int memoized_cut_rod () {

}

public int memoized_cut_rod_aux (int p[], int n, int r[]) {

}

public int bottom_up_cut_rod () {

}

public void extended_bottom_up_cut_rod () {

}

public void print_cut_rod_solution () {

for (int i = 0; i

System.out.print(i + "\t");

}

System.out.print(" ");

for (int i = 0; i

System.out.print(r[i] + "\t");

}

System.out.print(" ");

for (int i = 0; i

System.out.print(s[i] + "\t");

}

System.out.print(" ");

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

RodCut rc;

rc = new RodCut();

System.out.println("memoized_cut_rod starts ------------------");

System.out.println(rc.memoized_cut_rod());

System.out.println("memoized_cut_rod ends ------------------");

System.out.print(" ");

System.out.println("bottom_up_cut_rod starts ------------------");

System.out.println(rc.bottom_up_cut_rod());

System.out.println("bottom_up_cut_rod ends ------------------");

System.out.print(" ");

System.out.println("extended_bottom_up_cut_rod starts ------------------");

rc.extended_bottom_up_cut_rod();

rc.print_cut_rod_solution();

System.out.println("extended_bottom_up_cut_rod ends ------------------");

System.out.print(" ");

}

}

Instructions. You are provided one skeleton program named RodCut.java. The source files are available on Canvas in a folder named HW5. Please modify the skeleton code to solve the following tasks. Task 1 (40 pts). Implement the memoized.cut.rod) and memoized.cut.rod.aur ) function as discussed in Lecture 9. Task 2 (40 pts). Implement the bottom.up.cut rod) function as discussed in Lecture 9 Task 3 (20 pts). Implement the ertended.bottomup.cut.rod function as discussed in Lecture 9. Note: The parameters in some functions are different from the slides. You should not change the parameter for any function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

What are some of the possible scenes from our future?

Answered: 1 week ago