CS 1400 Final Review
Quiz
•
Computers
•
University
•
Medium
Kayleeq Martin
Used 4+ times
FREE Resource
Enhance your content in a minute
31 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
What is executed first in this code?
[Lecture 19]
The return statement
sum(vals)
The multiply
Answer explanation
The multiply cannot execute until its inputs are known, and the return won't happen until its operation is completed.
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which operation is performed first?
[Lecture 19]
add
divide
subtract
Answer explanation
The subtraction can't finish until both of its values are known, so it goes to func1.
The addition can't finish until both of its values are known, so it goes to func2.
The division can happen because y was passed as a parameter.
3.
MULTIPLE SELECT QUESTION
1 min • 1 pt
Which of the following are true of recursion or recursive functions?
[Lecture 19]
Recursion involves a base case and a recursive step.
The base case of a recursive function is the first iteration of the recursion.
Recursive functions invoke themselves to solve a smaller part of the same problem.
Recursive solutions involve iterating by adding one to a counting variable.
Answer explanation
Right Answers:
Recursive solutions always identify a base case and a recursive step/case.
Recursion involves a function calling itself repeatedly to whittle down the problem to the most trivial case.
Wrong Answers:
The base case is the simplest version of a problem (e.g. for the factorial problem it is when N is 1).
Recursive solutions progress by repeatedly calling the function with smaller versions of the problem, not by increasing by one.
4.
OPEN ENDED QUESTION
5 mins • Ungraded
Write two functions:
1) iter_factorial takes an integer as the parameter, returns the factorial of that parameter. The factorial must be solved iteratively (e.g. without recursion).
2) recurs_factorial takes an integer as the parameter, returns the factorial of that parameter. The factorial must be solved recursively.
[Lecture 19/Lab 12]
Evaluate responses using AI:
OFF
Answer explanation
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the base case in this code?
[Lecture 20]
number // 2
1 + mystery
return 1
number <= 1
Answer explanation
The base case is the simplest version of a problem.
The only answer option that involves checking the parameter (to decide if it's time to stop recursing) is number <= 1.
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What causes recursion to progress towards the base case?
[Lecture 20]
number // 2
1 + mystery
return 1
number <= 1
Answer explanation
Recursion progresses through the recursive step. This step has 2 parts: calling the function again, and making the problem smaller. In the case of the factorial example, this looks like factorial(n - 1).
For this problem, technically the whole line return 1 + mystery(number // 2) is the recursive step, but this question is specifically asking what is progressing this code to the base case. In other words, it's asking what part of the code is making the problem smaller. The only code doing that is number // 2.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the value of mystery(1)?
[Lecture 20]
0.5
0
1
Infinite recursion (Stack Overflow)
Answer explanation
1 is included in the base case (if number <= 1), so 1 is returned.
Create a free account and access millions of resources
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
35 questions
FINAL_EXAM (CFP_122)
Quiz
•
University
27 questions
Python3_big_test
Quiz
•
University
27 questions
TestOut Quiz CMT+ N/O
Quiz
•
10th Grade - University
27 questions
Programacion Heuristica
Quiz
•
University
28 questions
Microsoft 365 Unified Endpoint Management
Quiz
•
11th Grade - University
31 questions
java collections
Quiz
•
University
26 questions
Mobile & Telecommunication - BSC in CSE - Quiz 1
Quiz
•
University
30 questions
blitz
Quiz
•
University
Popular Resources on Wayground
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
4:3 Model Multiplication of Decimals by Whole Numbers
Quiz
•
5th Grade
10 questions
The Best Christmas Pageant Ever Chapters 1 & 2
Quiz
•
4th Grade
12 questions
Unit 4 Review Day
Quiz
•
3rd Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
15 questions
Solving Equations with Variables on Both Sides Review
Quiz
•
8th Grade
Discover more resources for Computers
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
7 questions
Different Types of Energy
Interactive video
•
4th Grade - University
7 questions
Transition Words and Phrases
Interactive video
•
4th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
7 questions
Biomolecules (Updated)
Interactive video
•
11th Grade - University
34 questions
Unit 5 Review - The Middle Ages in Europe-B
Quiz
•
9th Grade - University
26 questions
Day2 classwork: Permutation and combination
Quiz
•
2nd Grade - University
5 questions
Using Context Clues
Interactive video
•
4th Grade - University
