1.

What will be the lexicographical order of permutations formed from the array arr={1,2,3}?(a) {{2,1,3},{3,2,1},{3,1,2},{2,3,1},{1,2,3},{1,3,2}}(b) {{1,2,3},{1,3,2},{2,3,1},{2,1,3},{3,2,1},{3,1,2}}(c) {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}}(d) {{2,1,3},{3,1,2},{3,2,1},{2,3,1},{1,2,3},{1,3,2}}I got this question in an interview.Enquiry is from Number Theory topic in chapter Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (c) {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}}

Explanation: The NUMBER of permutations for the problem will be 6 according to the FORMULA 3P3. When ORDERED in LEXICOGRAPHICAL manner these will be {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}}.



Discussion

No Comment Found

Related InterviewSolutions