Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need to do a rotate right and rotate left methods with java as the first picture shows but the ones I did as you
I need to do a rotate right and rotate left methods with java as the first picture shows but the ones I did as you can see in the second picture are wrong but I can't find what I did wrong. Every time I test it shows the error that it is in the third picture. Can someone help me? (Sorry for my English). void rotateLeft (int [) a, int lo, int hi) Shifts the contents of aflo, hi) one position to the left, with the item at a [1o] wrapping around to a[hi-1]. For example, if int[] a { 1, 2, 3, 4, 5 }: = a becomes rotateLeft (a, 1, 5) I/ a becomes 2, 3, 4, 1, 5) 1, 3, 4, 5, 2 rotateLeft (a, 0, 4) // void rotateRight (int[] a, int lo, int hi) Shifts the contents of a[lo, hi) one position to the right, with the item at a [hi-1] wrapping around to a [lo]. For example, if int [ ] { 1, 2, 3, 4, 5 }: a = rotateRight (a, o, 4) // a becomes t 4, 1, 2, 3, 5 rotateRight (a, 1, 5) // a becomes t 1, 5, 2, 3, 4
I need to do a rotate right and rotate left methods with java as the first picture shows but the ones I did as you can see in the second picture are wrong but I can't find what I did wrong. Every time I test it shows the error that it is in the third picture. Can someone help me? (Sorry for my English).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started