Filters
Question type

Study Flashcards

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

A) True
B) False

Correct Answer

verifed

verified

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


A) O( n 2)
B) O( n )
C) O(log2 n )
D) O2

E) B) and D)
F) None of the above

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) myList[ i + 1 ] = itemToInsert
B) myList[ j ] = itemToInsert
C) myList[ j + 1 ] = itemToInsert
D) myList[ i ] = itemToInsert

E) All of the above
F) C) and D)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) linear
B) quadratic
C) exponential
D) logarithmic

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

A bubble sort always requires approximately n2 comparisons.

A) True
B) False

Correct Answer

verifed

verified

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


A) elapsed time profiling
B) byte-code assembly
C) complexity analysis
D) memory usage analysis

E) All of the above
F) A) and C)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) linear sort
B) bubble sort
C) insertion sort
D) selection sort

E) B) and D)
F) None of the above

Correct Answer

verifed

verified

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


A) the beginning of the list
B) a random spot in the list
C) the end of the list
D) the middle of the list

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

How many loops are found in a typical insertion sort?


A) 1
B) 2
C) 3
D) 4

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

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?


A) using a millisecond counter
B) counting instructions
C) determining memory usage
D) convert the algorithm to byte code

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

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 >


A) myCount
B) elapsed
C) start
D) x

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

What is the best case performance of a sequential search?


A) O n
B) linear
C) quadratic
D) O(1)

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

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


A) O( n 2)
B) O( n )
C) O(log2 n )
D) O2

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

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


A) exponential
B) logarithmic
C) quadratic
D) linear

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer