#Why is the answer B ( APCS A )

58 messages ยท Page 1 of 1 (latest)

sleek tartan
hard wharfBOT
#

โŒ› This post has been reserved for your question.

Hey @sleek tartan! Please use /close or the Close Post button 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.

silent plank
#

which question are you asking about

fossil portal
#

prob 10

silent plank
#

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

fossil portal
#

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

silent plank
#

yeah that's all correct

#

im confused on what you're asking then

cerulean charm
#

(You're not talking to OP)

silent plank
#

wtf

sleek tartan
#

sorry i forgot to say 11

#

sorry!

silent plank
#

๐Ÿ’€

#

ok let's start over

#

so what do you think the answer is

sleek tartan
#

i have no clue

fossil portal
#

๐Ÿ˜ญ

#

11

#

it hgouth 10

#

oops

sleek tartan
#

thanks for heloping with 10 that helped me understand it more

hard wharfBOT
silent plank
#

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

sleek tartan
#

yes, because it doesnt have it in the ar5ray so it wont even return any thing right

silent plank
#

right, but it's not going to loop forever

sleek tartan
#

i thought it was while

#

but it aint

silent plank
#

once it decrements down to -1, it's going to error

silent plank
sleek tartan
#

the lenght one

#

but i was just guessing

silent plank
#

ah no that wouldn't work at all

sleek tartan
#

oh...

silent plank
#

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

sleek tartan
#

oh yeah! obvi!

silent plank
#

so doing index < array.length isn't useful here because it'll always be true

sleek tartan
#

so it stops when the list is less than 0

silent plank
silent plank
sleek tartan
#

thank you ThatGuy Chris! you are always helping me whenever i post and giving detailed responses.

hard wharfBOT
sleek tartan
#

and thank you seacousin too

#

and kyochan you have hlped me before too

silent plank
#

did you figure out why it's B and not D

silent plank
#

or A

sleek tartan
silent plank
#

cool