Find the lexicographic ordering of the bit strings given below based on the ordering 0 < 1.
(A) 001
(B) 010
(C) 011
(D) 0001
(E) 0101
Choose the correct answer from the options given below:
1.001 < 010 < 011 < 0001 < 0101
2.0001 < 001 < 010 < 0101 < 011 ✓ Correct
3.0001 < 0101 < 001< 010 < 011
4.001 < 010 < 0001 < 0101 <011
Solution
The correct answer is option 2
Explanation:
Lexicographic order is nothing but dictionary order.
To determine the order of strings, we need to compare each bit of all the strings one by one.
For example, take 001 and 010. Here, the second bits of the strings are 0, 1 respectively.
Since 0 < 1 as per the given question, 001<010.
Similarly, 0001 < 001 < 010 < 0101 < 011
Alternate Method
Replace 0 with A and 1 with B and follow dictionary order
AAAB<AAB<ABA<ABAB<ABB