HW2: Lexicographic order in the case of a further tie

f
fernandoalonzi_ (270 points)
1 2 3
asked Nov 2, 2021 in HW2 by fernandoalonzi_ (270 points)
recategorized Nov 7, 2021 by andrea.sterbini
When comparing two strings in lexicographic order, should we also consider '  '? Because ord('  ') comes before the others and this means that if a string starts with '  ' compared to another that doesn't, it wins the comparison.
186 views

2 Answers

Best answer
Ganni02 (4920 points)
1 2 15
answered Nov 2, 2021 by Ganni02 (4,920 points)
selected Nov 2, 2021 by andrea.sterbini
As part of the initial process, you would need to remove all white spaces, hence the ' ' should be ignored.
leonardo_13 (1530 points)
6 13 20
commented Nov 8, 2021 by leonardo_13 (1,530 points)
Great answer.
s
saad rahman (540 points)
0 0 3
answered Nov 2, 2021 by saad rahman (540 points)
"The number of non-space characters is, however, equal
for each sequence". I think it implies that we have to consider non-space characters as mentioned in the assignment.
a
angelaob (1190 points)
2 4 7
commented Nov 2, 2021 by angelaob (1,190 points)
I think it means that after removing possible white spaces and tabs, the number of characters becomes the same for every string