Question
I need help to create a binary search that I need to create a AlphaFinder class that implments a third comparator I already post this
I need help to create a binary search that I need to create a AlphaFinder class that implments a third comparator I already post this question twice can some one please help me thank you
2) At the end of main is a comment to search for the string bbbw. Add the appropriate code to perform a binary search for that string and print the location where it was found. You will need to implement a third comparator, AlphaFinder, for this purpose.
Hint: You need to use the substring and charAt methods in the String class.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class SortRunner
{
public static void main(String[] args) {
ArrayList
al.add("aaa888q");
al.add("aaa888q");
al.add("aaa555q");
al.add("aaa333q");
al.add("aaa888p");
al.add("aaa888a");
al.add("bbb111z");
al.add("bbb222w");
al.add("ccc777a");
al.add("eee888b");
al.add("zzz000c");
al.add("zzz666d");
al.add("ppp333e");
al.add("ppp111f");
ReverseWordSorter rws = new ReverseWordSorter();
Collections.sort(al,rws);
System.out.println("ReverseWord order:");
for(String s : al)
System.out.println(s);
LetterNumberSorter ls = new LetterNumberSorter();
Collections.sort(al,ls);
System.out.println("Letter-Number order:");
for(String s : al)
System.out.println(s);
// NumberLetterSorter nls = new NumberLetterSorter();
// Collections.sort(al,nls);
// System.out.println("Number-Letter order:");
// for(String s : al)
// System.out.println(s);
// Add code to search for the string "bbbw".
}
}
import java.util.Comparator;
public class ReverseWordSorter implements Comparator
{
public int compare(String a, String b)
{
return -1 * (a.compareTo(b)) ;
}
}
import java.util.Comparator; public class LetterNumberSorter implements Comparator
import java.util.Comparator;
public class NumberLetterSorter implements Comparator
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started