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
Step: 1
Get Instant Access to Expert-Tailored 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