Help me please greedy(double[] points, double[] time, double timelimit) {6.ArrayList retTasks = new ArrayList();ArrayList allTasks = new ArrayList();double[] ppt = new double[points.length];for...


Help me please


public List<Integer> greedy(double[] points, double[] time, double timelimit) {<br>6.<br>ArrayList<Integer> retTasks = new ArrayList<>();<br>ArrayList<Integer> allTasks = new ArrayList<>();<br>double[] ppt = new double[points.length];<br>for (int i=0; i< points.length; i++) {<br>allTasks.add(i);<br>9.<br>10<br>11<br>pptli] = EXPR1;<br>12<br>13<br>14<br>// Sorts tasks in decreasing order of ppt<br>15<br>allTasks.sort(Comparator.comparing((Integer t)->ppt[t]).reversed());<br>16<br>double timeRemaining = timelimit;<br>17<br>18<br>for (int task : allTasks) {<br>19<br>if (EXPR2) {<br>20<br>retTasks.add(task);<br>21<br>timeRemaining -- time[task];<br>22<br>23<br>24<br>return retTasks;<br>25<br>Recall that there are N tasks in total (that is, points and time both have length N). What is<br>the big O runtime complexity of the greedy method in terms of N? Briefly explain your<br>answer referencing the code.<br>

Extracted text: public List greedy(double[] points, double[] time, double timelimit) { 6. ArrayList retTasks = new ArrayList<>(); ArrayList allTasks = new ArrayList<>(); double[] ppt = new double[points.length]; for (int i=0; i< points.length;="" i++)="" {="" alltasks.add(i);="" 9.="" 10="" 11="" pptli]="EXPR1;" 12="" 13="" 14="" sorts="" tasks="" in="" decreasing="" order="" of="" ppt="" 15="" alltasks.sort(comparator.comparing((integer="" t)-="">ppt[t]).reversed()); 16 double timeRemaining = timelimit; 17 18 for (int task : allTasks) { 19 if (EXPR2) { 20 retTasks.add(task); 21 timeRemaining -- time[task]; 22 23 24 return retTasks; 25 Recall that there are N tasks in total (that is, points and time both have length N). What is the big O runtime complexity of the greedy method in terms of N? Briefly explain your answer referencing the code.

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here