Hello All,

I came across a question wherein I need to find an element in the array.However, it's given that the array has been rotated many number of times and initially the array elements were sorted in an increasing order.I just wanted to know what is meant by rotating an array? Does it mean simply changing order of the elements or it implies something else? I know this might be a stupid question to ask.

Thanks.

Recommended Answers

All 4 Replies

I assume it means shifting all the elements one place to the right with the last element in the array wrapping around to be the first element in the array with every rotation.

When I use the term, it means what aspire1 said, except that you can shift the elements N places, for some value of N.

Either way, "many rotations" gets the same meaning, and the combined effect of many rotations is the same as that of one of rotation, or a small number of aspire1's variety.

Initial array is 1,2,3,4,5,6,7,8,9,10
After rotating it 3 times 8,9,10,1,2,3,4,5,6,7

Thanks for the replies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.