public ArrayList> computeFDList(ArrayList dataSet) { /*TODO ADD YOUR CODE HERE*/ ArrayList> result = new ArrayList>(); int frequency = 1; Collections.sort(dataSet); for (int i = 0; i entry = new...


Please refactor the code block, I give likes, thanks!


public ArrayList<Entry<E, Integer>> computeFDList(ArrayList<E> dataSet) {<br>/*TODO ADD YOUR CODE HERE*/<br>ArrayList<Map. Entry<E, Integer>> result = new ArrayList<Map.Entry<E, Integer>>();<br>int frequency = 1;<br>Collections.sort(dataSet);<br>for (int i = 0; i < dataSet.size() - 1; i++) {<br>if (dataSet.get(i).equals(dataSet.get(i + 1))) {<br>frequency += 1;<br>}<br>else {<br>Map. Entry<E, Integer> entry = new AbstractMap.SimpleEntry<E, Integer>(dataSet.get(i), frequency);<br>result.add(entry);<br>frequency = 1;<br>}<br>}<br>Map. Entry<E, Integer> entry = new AbstractMap.SimpleEntry<E, Integer>(dataSet.get(dataSet.size() - 1), frequency);<br>result.add(entry);<br>return result; //Dummy Return<br>}<br>

Extracted text: public ArrayList<>> computeFDList(ArrayList dataSet) { /*TODO ADD YOUR CODE HERE*/ ArrayList> result = new ArrayList>(); int frequency = 1; Collections.sort(dataSet); for (int i = 0; i < dataset.size()="" -="" 1;="" i++)="" {="" if="" (dataset.get(i).equals(dataset.get(i="" +="" 1)))="" {="" frequency="" +="1;" }="" else="" {="" map.=""> entry = new AbstractMap.SimpleEntry(dataSet.get(i), frequency); result.add(entry); frequency = 1; } } Map. Entry entry = new AbstractMap.SimpleEntry(dataSet.get(dataSet.size() - 1), frequency); result.add(entry); return result; //Dummy Return }

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here