#Why is the answer B ( APCS A )
58 messages ยท Page 1 of 1 (latest)
โ This post has been reserved for your question.
Hey @sleek tartan! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
which question are you asking about
prob 10
so what do you think the answer is
actually no
what do you think about each of the test cases
how do you think they will behave
1st one wont always cause an error since if the one value is 5, it will return an index of 0
2nd one will always have an error since if data doesnt have the target, the recursive method will always keep running until it goes out of bounds which then causes an ArrayIndexOutOfBoundsException
3rd one is fine because since it has the target, it will return an index without an error
(You're not talking to OP)
wtf
i have no clue
thanks for heloping with 10 that helped me understand it more
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
and that's why you don't answer other peoples' questions
anyways
so from question 10, do you understand what exactly the issue in the code is
yes, because it doesnt have it in the ar5ray so it wont even return any thing right
right, but it's not going to loop forever
once it decrements down to -1, it's going to error
which one?
ah no that wouldn't work at all
oh...
that's checking if the number is less than the array's length
but we start at the array's length, and we keep decrementing it, the - 1 in the recursive call
so the value keeps decreasing
oh yeah! obvi!
so doing index < array.length isn't useful here because it'll always be true
so it stops when the list is less than 0
this is the cause of the error, you need to prevent that somehow
yeah that's what you need to do
thank you ThatGuy Chris! you are always helping me whenever i post and giving detailed responses.
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
did you figure out why it's B and not D
or A
yes!
cool