Lexographic strings

b comes afterr a lexographically is it right to say as b comes after a alphabetically and is it correct to say string of length 5 is lexographically greater than length of string 10

abcdeghijk bcd I think first one will be lexographically greater

b comes after a my first question is alphabetically and lexographically same

string of length 5 will it be lexographicaly greater than string of length of 5

my 3 rd question “abcdefghijk” and “bcd” is first one lexographically gretaer than second string

@AyushKumar9032 Lexicographical sorting is not only dependent on length. Lexicographical sorting means you have to sort in the same way as a dictionary order where first you compare the characters…if the characters are same in both string then only you check their lengths.

Say for example:
bat and batman
prefix bat is similar in both the strings but length of bat is less that length of batman so bat will come before batman in lexicographic order.

here bcd is lexicographically greater than “abcdefghijk”

1 Like