

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The answers and exercises for the recursion section of a csc 227 (computer science fundamentals) practice quiz. The exercises include completing methods that use recursion to find the number of 100s in an integer array, find the range of integers in an array, and get an element at a given index in a recursivelist. The document also includes helper methods and private methods for some exercises.
Typology: Quizzes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


public int numberOf100s(int[] x, int n) { if (n == 0) return 0; else if (x[n - 1] == 100) return 1 + numberOf100s(x, n - 1); else return 0 + numberOf100s(x, n - 1); // 0 not necessary } -or- public int numberOf100s(int[] x, int n) { if (n == 0) return 0; else { int hasOne = 0; if (x[n - 1] == 100) hasOne++; return hasOne + numberOf100s(x, n - 1); } }
public int range(int[] x, int n) {
// Complete get here (there is no size method, use the instance variable n) public E get(int index) {