CS 1400 Final Review

CS 1400 Final Review

University

31 Qs

quiz-placeholder

Similar activities

Examen Unidades 3-4

Examen Unidades 3-4

University

29 Qs

Midterm Exam - CTCC0323

Midterm Exam - CTCC0323

University

33 Qs

Computer Classification

Computer Classification

University

34 Qs

Final de Servicios WEB

Final de Servicios WEB

University

27 Qs

Kompetencia 5-6 teszt

Kompetencia 5-6 teszt

4th Grade - University

28 Qs

PRUEBA FINAL COMPUTACIÓN SEXTO

PRUEBA FINAL COMPUTACIÓN SEXTO

1st Grade - University

29 Qs

ICTC0613 - Midterms Exam

ICTC0613 - Midterms Exam

University

30 Qs

CS 1400 Final Review

CS 1400 Final Review

Assessment

Quiz

Computers

University

Medium

Created by

Kayleeq Martin

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

31 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Media Image

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

Media Image

Which operation is performed first?

[Lecture 19]

add

divide

subtract

print

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

Media Image

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

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

Media Image

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

Media Image

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?