Test Your Knowledge 5
Test your knowledge of recursion applied to arrays by solving quiz questions focused on counting, inverting, replacing, and sorting. This lesson prepares you to use recursion effectively in array-based problems before advancing to recursion with other data structures.
We'll cover the following...
We'll cover the following...
Quiz on Arrays
This Quiz will take approximately 10 minutes.
1.
The function below prints a string recursively, meaning 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 the base case of the following code be?
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 use recursion to solve problems with data structures.