Exam 3: Searching, Sorting, and Complexity Analysis

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

What should the missing code be in the following algorithm if the goal is to determine how many seconds the algorithm runs? start = time.time() MyCount = 1 For x in range(100): MyCount *= x Elapsed = time.time() - < missing code >

(Multiple Choice)
4.8/5
(40)

Which of the following is a method to estimate the efficiency of an algorithm that predicts the amount of work an algorithm performs regardless of the platform?

(Multiple Choice)
4.9/5
(45)

In the following code, what is the algorithm's complexity? minIndex = 0 CurrentIndex = 1 While currentIndex < len(lyst): If lyst[currentIndex] < lyst[minIndex]: MinIndex = currentIndex CurrentIndex += 1 Return minIndex

(Multiple Choice)
4.8/5
(33)

Which method of determining the efficiency of algorithms allows you to rate them independently of timings or instruction counts?

(Multiple Choice)
4.9/5
(30)

What is the best case performance of a sequential search?

(Multiple Choice)
4.8/5
(40)

In the first step of the quicksort, you begin by selecting the item at the list's midpoint.

(True/False)
4.9/5
(44)

What should the missing code be in the following insertion sort algorithm? i = 1 While i < len(myList): ItemToInsert = myList[i] J = i - 1 While j >= 0: If itemToInsert < myList[j]: MyList[j + 1] = myList[j] J -= 1 Else: Break < missing code > I += 1

(Multiple Choice)
4.9/5
(43)

In terms of complexity, what is the average case for an insertion sort?

(Multiple Choice)
4.9/5
(36)

A bubble sort always requires approximately n2 comparisons.

(True/False)
4.9/5
(39)

Algorithms with linear behavior do more work than those with quadratic behavior.

(True/False)
4.8/5
(38)

How many loops are found in a typical insertion sort?

(Multiple Choice)
4.7/5
(30)

Using a binary search, a list of 1 million items requires only 20 comparisons.

(True/False)
4.7/5
(39)

How can the performance complexity of the following algorithm be described? For x in range(numIterations): Value = value * x Print(value)

(Multiple Choice)
4.8/5
(35)

In the average case, where many items in a list are out of order, an insertion sort is linear.

(True/False)
4.7/5
(42)

The bubble sort has a complexity of O( n 2).

(True/False)
4.9/5
(33)

This bubble sort has the effect of bubbling the largest items to the end of the list.

(True/False)
4.9/5
(31)

In a binary search of an ascending order list, where does the search algorithm begin the search?

(Multiple Choice)
4.8/5
(44)

Which type of algorithm is analogous to how many people organize playing cards in their hands?

(Multiple Choice)
4.9/5
(38)

In terms of complexity, what is the worst-case scenario for an insertion sort?

(Multiple Choice)
4.9/5
(32)

The sequential search algorithm does more work to find a target at the beginning of a list than at the end of the list.

(True/False)
4.8/5
(43)
Showing 21 - 40 of 50
close modal

Filters

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