Question: This is java problem assume that you have 1d array in the element you have [ ] [ ] [ ] [ ] [T] [

This is java problem

assume that you have 1d array in the element you have

[ ] [ ] [ ] [ ] [T] [ ] [ ] [ ] [ ]

0 1 2 3 4 5 6 7 8

T is target at first it start at the middle of the array which is in this case at 4

the user wanted to move the T 3 array back which is mean at array 1 so like this in this point it is allowed

[ ] [T] [ ] [ ] [ ] [ ] [ ] [ ] [ ]

0 1 2 3 4 5 6 7 8

what user cant allowed is moving it 6 time back because it will cause array out of bound instead of giving an exception

the program should place the T in the array 0

so first like this

[ ] [ ] [ ] [ ] [T] [ ] [ ] [ ] [ ]

0 1 2 3 4 5 6 7 8

then the final result should be

[T] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]

0 1 2 3 4 5 6 7 8

reminder this is problem of java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!