Recursion

AP Computer Science A· difficulty 4/5

Count occurrences of <code>target</code> in array recursively returns

  • A

    Cannot count recursively

  • B

    Sum of array

  • C

    0 + (1 if match) + count(rest)

    check_circle
  • D

    Length of array

Explanation

Each call: contribute 1 if match; recurse on smaller array.

Want 10 more like this — adaptive to your weak spots?

Related questions