...

/

Test Your Knowledge 5

Test Your Knowledge 5

Let's take a small quiz!

Quiz on Arrays

This Quiz will take maximum 10 minutes.

1.

The function below prints a string recursively, such that one character is printed in each recursive call.

def printArray(array, startIndex, length) :
  # Base case
  _______________________________
  
  print(arr[startIndex] + "\t")
  
  #Recursively calling printArray to print next element in the array
  printArray(array, startIndex + 1, length)

What should be the base case of the following code?

A.
if startIndex >= length :
  return
B.
if startIndex <= length :
   return
C.
if startIndex >= length/2 :
   return
D.
if startIndex >= 0 :
   return

1 / 3

In the next chapter, we will be using recursion to solve problems dealing with data structures.