Exam 3: Searching, Sorting, and Complexity Analysis

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

All algorithms that perform the same task take the same amount of time to complete.

Free
(True/False)
4.7/5
(36)
Correct Answer:
Verified

False

The number of Python instructions executed in an algorithm will differ from the number of machine language instructions executed.

Free
(True/False)
4.8/5
(30)
Correct Answer:
Verified

True

Why is the efficiency of algorithms desirable?

Free
(Multiple Choice)
4.8/5
(43)
Correct Answer:
Verified

A

An algorithm that uses the exact same Python code run on two different machines should have the same performance data.

(True/False)
4.9/5
(36)

On sorted data, you can use a binary search.

(True/False)
4.8/5
(41)

How can the following algorithm be described? Position = 0 While position < len(lyst): If target == lyst[ position ]: Return position Position += 1 Return -1

(Multiple Choice)
4.8/5
(35)

What does the Python time() function return?

(Multiple Choice)
4.9/5
(40)

What term best describes the following code? X = myList[ i ] MyList[ i ] = myList[ j ] MyList[ j ] = x

(Multiple Choice)
4.8/5
(34)

What is the worst-case complexity of a binary search?

(Multiple Choice)
4.8/5
(41)

The merge sort employs a recursive, divide-and-conquer strategy to break the O( n2 ) barrier.

(True/False)
4.8/5
(39)

The amount of work of a logarithmic algorithm is proportional to the log2 of the problem size.

(True/False)
4.8/5
(35)

Which of the following is a common way to measure the time cost of an algorithm?

(Multiple Choice)
4.8/5
(29)

In a bubble sort, each pass through the main loop selects a single item to be moved.

(True/False)
4.8/5
(39)

In a selection sort, the outer loop executes n - 1 times.

(True/False)
4.9/5
(33)

Python's in operator is implemented as a method named __contains__ in the list class.

(True/False)
4.8/5
(38)

The result of fib(4) is 8.

(True/False)
4.8/5
(35)

How can an algorithm be described in which the work it does grows as a function of the square of the problem size?

(Multiple Choice)
5.0/5
(37)

The in operator performs a binary search algorithm.

(True/False)
4.8/5
(49)

The first two numbers in the Fibonacci sequence are 1s, and each number after that is the sum of the previous two numbers.

(True/False)
4.8/5
(42)

What is the complexity of a selection sort?

(Multiple Choice)
4.9/5
(44)
Showing 1 - 20 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)