Python final second half

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

How many times will the gcd function be called (including the initial call) to determine the greatest common divisor of 728 and 105?

3

What is recursion?

A problem solution defined in terms of itself

What is infinite recursion?

A situation in which the base case is never reached

Some problems can only be solved using recursion.

False

The insertion sort algorithm only works on a list of integers.

False

The recursive solution for reversing a string is more straightforward than its iterative solution.

False

The selection_sort function uses a single loop to perform sorting by comparing each element exactly once.

False

Which of the following algorithms is generally faster than the others?

Merge sort (The answer is not Bubble, Insertion, Selection sort)

Which of the following is NOT a quadratic sorting algorithm?

Quick sort (The answer is not Insertion, Bubble, selection)

Which of the following best summarizes the insertion sort algorithm?

Repeatedly insert each value into its correct position

Which of the following best summarizes the selection sort algorithm?

Repeatedly select the smallest remaining value and put it in its sorted position

Which of the following is NOT a logarithmic sorting algorithm?

Selection sort ( The answer is not Quick, Merge, Heap sort)

When comparing sorting algorithms, what does the value n represent?

The number of elements in the list to be sorted

What is the base case of a recursive definition?

The situation that requires no recursion

Big O notation is used to categorize algorithms by how efficient they are at solving a problem.

True

Each call to a recursive function has its own parameter values.

True

Inserting a value in its correct position may require shifting one or more values to create an insertion point.

True

Multiple strategies can be used to sort a list of elements.

True

Selection sort requires minimal extra memory as it can be performed in place in an array.

True

The is_palindrome function can be passed the string to check as its only argument.

True

The Towers of Hanoi solution is an example of what kind of complexity?

exponential complexity

A new string is passed to the recursive is_palindrome function each time it is called.

false

The arguments to both recursive calls in the move_tower function are the same.

false

The base case of the recursive Towers of Hanoi solution is a stack containing no disks.

false

The iterative solution to Towers of Hanoi is more efficient than the recursive version.

false

The recursive palindromes program considers a string a palindrome if the outermost characters match the innermost characters.

false

The string "taco cat" would be considered a palindrome by the recursive palindromes program.

false

Which of the following is NOT a base case for the recursive palindromes program?

the first and last character of the substring match

In Python, swapping two values in a list can be done with one line of code.

true

The insertion_sort function uses two loops, one to scan the list and another to shift values in the list.

true


संबंधित स्टडी सेट्स

Combo with "Psych Lesson 1" and 15 others

View Set

Maternal Newborn ATI 2019 Practice B

View Set

Week 4-Skeletal systems and joints

View Set