Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Array Sorted why it would not work. JAVA. public static ArrayList<Term> organize

ID: 3727525 • Letter: A

Question

Array Sorted why it would not work. JAVA.

public static ArrayList<Term> organizePrefixOrder(ArrayList<Term> a, ArrayList<Term> b) {
for (int i = 0; i < a.size(); i ++){
for (int j = 0; j < i; j++){
if (a[i].compareTo(a[j]<0)){
String ch = a[i];
a[i] = a[j];
a[j] = ch;
}
}
}
for (Term term:
array) {
b.add(term);
}

return b;

}

Array list a has inside it

BB, BA, BC, AA, ZZ

Array list b has nothing inside it.

I want that array list b has sorted version of array list a

so AA, BA,BB, BC, ZZ

Explanation / Answer

----------------------------------------------------------------------------------------------------------------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote