0

I'm trying to do a homework assignment for my Java class. The assignment is to make a method that will run a binary search through an array of strings, and return the position. The teacher told us to assume the elements of the array were in ascending order. This means the lexicographic number of each word increases towards the end of the array. For testing if it works, I used:

String[] names = {"H", "He", "Hel", "Hell",
"Hello", "Hello ", "Hello S", "Hello Si",
"Hello Sir", "Hello Sir."};

`I need to find out what the lexicographic number is of a string. Is there a pre-made method I could use for that, or do I have to make my own one to calculate it for me? If it turns out I will have to make my own, I will just put it down underneath this text, for other people to use.

Devon
  • 3
  • 6

1 Answers1

0

I fact, you don't have to look for the ''lexicographic number'' of a string, because they are the origin of what we call lexicography itself . Basically comparing strings is done letter by lettre in the same position starting from the left, for example ab>aa because the first characters are the same in both, but in the second b>a

Mustapha Belmokhtar
  • 1,231
  • 8
  • 21