Unit 10 Quizziz Review

Unit 10 Quizziz Review

12th Grade

20 Qs

quiz-placeholder

Similar activities

X and Y Intercepts

X and Y Intercepts

9th - 12th Grade

22 Qs

IST P-STEM Unit 1 Hardware and Python Review

IST P-STEM Unit 1 Hardware and Python Review

8th - 12th Grade

20 Qs

Techniques of Integration

Techniques of Integration

10th - 12th Grade

15 Qs

X and Y Intercepts

X and Y Intercepts

8th - 12th Grade

15 Qs

Linear Intersections

Linear Intersections

10th Grade - University

15 Qs

Techniques of Integration BC

Techniques of Integration BC

11th Grade - University

20 Qs

Functions Quiz

Functions Quiz

7th - 12th Grade

20 Qs

Graphs Using X and Y Intercepts Linear Equations

Graphs Using X and Y Intercepts Linear Equations

8th Grade - University

19 Qs

Unit 10 Quizziz Review

Unit 10 Quizziz Review

Assessment

Quiz

Mathematics

12th Grade

Hard

Created by

Nichole Niebur

Used 1+ times

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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}.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?