+1 vote
in Data Structures & Algorithms I by (110k points)
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, 4

I need to ask this question from Arrays Types topic in portion Arrays Types of Data Structures & Algorithms I

The question was posed to me in a national level competition.

1 Answer

+1 vote
by (408k points)
selected by
 
Best 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}.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...