You can create a navigation map or set (for example, TreeMap or TreeSet) for 2 (with keys in the usual order) and 3 (keys in the reverse order)
For option 4, you can create a collection with a key for each starting letter. You can simplify this depending on your requirement. This can lead to more space being used, but get O (log n) lookup time.
Peter Lawrey
source share