1.

What will be the resulting array after rotating arr[]={1, 2, 3, 4, 5} by 2?(a) 2, 1, 3, 4, 5(b) 3, 4, 5, 1, 2(c) 4, 5, 1, 2, 3(d) 1, 2, 3, 5, 4I need to ask this question from Arrays Types topic in portion Arrays Types of Data Structures & Algorithms IThe question was posed to me in a national level competition.

Answer»

Correct OPTION is (b) 3, 4, 5, 1, 2

To explain: When the given ARRAY is ROTATED by 2 then the resulting array will be

Rotation 1: {2,3,4,5,1}

Rotation 2: {3,4,5,1,2}.

THUS, the final array is {3,4,5,1,2}.



Discussion

No Comment Found

Related InterviewSolutions