
Unit 10 Quizziz Review
Authored by Nichole Niebur
Mathematics
12th Grade
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following recursive method, which is intended to display the binary equivalent of a decimal number. For example, toBinary(100) should display 1100100.
Which of the following can replace /* missing code */ so that toBinary works as intended?
System.out.print(num % 2);
toBinary(num / 2);
System.out.print(num / 2);
toBinary(num % 2);
toBinary(num % 2);
System.out.print(num / 2);
toBinary(num / 2);
System.out.print(num % 2);
toBinary(num / 2);
System.out.print(num / 2);
Answer explanation
This will recursively call toBinary on the value of num / 2 until the value of the parameter is less than 2. Then either 0 or 1 is displayed depending on whether the parameter is even or odd. This represents the leftmost digit of the binary equivalent. After the base case is reached, either 0 or 1 will continue to be displayed for each of the previous recursive calls to toBinary.
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following recursive method, which is intended to return a String with any consecutive duplicate characters removed. For example, removeDupChars("aabcccd") returns "abcd".
Which of the following can replace /* missing code */ so that removeDupChars works as intended?
return removeDupChars(str.substring(2));
return removeDupChars(str.substring(1)) + str.substring(0, 1);
return removeDupChars(str.substring(2)) + str.substring(1, 2);
return str.substring(0, 1) + removeDupChars(str.substring(1));
return str.substring(1, 2) + removeDupChars(str.substring(2));
Answer explanation
This is executed when two consecutive characters are not the same. The first character in str is concatenated to the string returned from the recursive call to removeDupChars. Each time removeDupChars is recursively called, it uses the string that begins at the second character of str, thus working down to the base case. When the base case is reached, the string that is returned from each recursive call to removeDupChars represents an accumulation of the previously returned strings and is concatenated to the single character that was extracted before the recursive call.
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following method, which is intended to return the sum of all the even digits in its parameter num. For example, sumEvens(15555234) should return 6, the sum of 2 and 4.
Which of the following can be used as a replacement for /* missing statement */ so that the sumEvens method works as intended?
return sumEvens(num % 10);
return sumEvens(num / 10);
return num % 10 + sumEvens(num % 10);
return num % 10 + sumEvens(num / 10);
return num / 10 + sumEvens(num % 10);
Answer explanation
This statement is executed in the case where num has more than one digit and the rightmost digit is even. In this case, the method should return the rightmost digit (num % 10) plus the result of calling sumEvens recursively on all digits of num but the rightmost digit (sumEvens(num / 10)).
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following method.
Which of the following best describes the output produced by the method call mystery(val) ?
All integers from 1 to val, separated by spaces
All integers from val to 1, separated by spaces
The digits of val in their original order, separated by spaces
The digits of val in reverse order, separated by spaces
The last digit of val, then a space, then the first digit of val
Answer explanation
Each method call prints the current value of n and calls mystery recursively with the parameter n - 1. The base case is when the parameter n has the value 1; in this case, 1 is printed and no further recursive calls are executed.
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following recursive method.
Which of the following best describes the result of the call doSomething(myString) ?
The method call returns a String containing the contents of myString unchanged.
The method call returns a String containing the contents of myString with the order of the characters reversed from their order in myString.
The method call returns a String containing all but the first character of myString.
The method call returns a String containing only the first and second characters of myString.
The method call returns a String containing only the first and last characters of myString.
Answer explanation
When there is at least one character in str, the method returns the first character of str concatenated with the value returned by a recursive call. The parameter of the recursive call is the substring of str starting at the second character. As a result, the original string is reconstructed recursively.
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following recursive method.
Which of the following best describes the value returned by the method call calc(num) ?
The int value 9
The leftmost digit of num
The rightmost digit of num
The number of digits in num
The result of the integer division of num by 10
Answer explanation
In each recursive call, the rightmost digit of the parameter n is truncated. In the final call to calc, n contains only a single digit. The value of n, or the leftmost digit of the parameter num in the original call to calc, is returned.
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment, which appears in a method in the same class as mergeSortHelper and merge.
int[] arr1 = {9, 1, 3, 5, 4};
int[] temp = new int[arr1.length];
mergeSortHelper(arr1, 0, arr1.length - 1, temp);
Which of the following represents the arrays merged the first time the merge method is executed as a result of the code segment above?
{9} and {1} are merged to form {1, 9}.
{1, 9} and {3} are merged to form {1, 3, 9}.
{1, 9} and {5, 4} are merged to form {1, 4, 5, 9}.
{1, 3, 9} and {5} are merged to form {1, 3, 5, 9}.
{1, 3, 9} and {4, 5} are merged to form {1, 3, 4, 5, 9}.
Answer explanation
The merge method appears after both recursive calls in the mergeSortHelper method, so it is not called until the condition from < to evaluates to false and there are no more recursive calls to execute. This occurs when the two parts of the array to merge each contain one element. The original array is split into {9, 1, 3} and {5, 4}. The array segment {9, 1, 3} is split into {9, 1} and {3}. The array segment {9, 1} is split into {9} and {1} and these two array segments are merged to form {1, 9}.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
More Ordering Fractions Decimals Percents Greatest to Least
Quiz
•
6th Grade - University
15 questions
Solve by Completing the Square
Quiz
•
9th Grade - University
20 questions
Q3 Summative Test 2-GEOMETRY
Quiz
•
8th Grade - University
15 questions
Plant Transport Systems Quiz
Quiz
•
5th Grade - University
20 questions
INTEGRATIONS
Quiz
•
12th Grade - University
17 questions
Review for Test Chapter 1
Quiz
•
10th Grade - University
20 questions
Adding and Subtracting Equations
Quiz
•
6th Grade - University
17 questions
Math wk 5
Quiz
•
9th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
29 questions
Alg. 1 Section 5.1 Coordinate Plane
Quiz
•
9th Grade
22 questions
fractions
Quiz
•
3rd Grade
11 questions
FOREST Effective communication
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
Discover more resources for Mathematics
20 questions
SSS/SAS
Quiz
•
9th - 12th Grade
14 questions
Making Inferences From Samples
Quiz
•
7th - 12th Grade
23 questions
CCG - CH8 Polygon angles and area Review
Quiz
•
9th - 12th Grade
20 questions
Domain and Range Spiral Review
Quiz
•
9th - 12th Grade
10 questions
Dividing a polynomial by a monomial
Quiz
•
10th - 12th Grade
16 questions
Explore Triangle Congruence Theorems
Quiz
•
9th - 12th Grade
17 questions
Interpreting Graphs Of Functions
Quiz
•
8th - 12th Grade
15 questions
Explore Exponential Functions and Their Applications
Quiz
•
9th - 12th Grade