Filters
Question type

Study Flashcards

The order of complexity of a linear-time algorithm is On .

A) True
B) False

Correct Answer

verifed

verified

What type of algorithm is the following code? N = len(myList) While n > 1: I = 1 While i < n: If myList[ i ] < myList[ i - 1 ]: Swap(myList, i, i - 1) I += 1 N -= 1


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

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

Correct Answer

verifed

verified

The performance of an algorithm in a single loop is linear.

A) True
B) False

Correct Answer

verifed

verified

In a selection sort, the inner loop is executed n - 2 times for every pass through the outer loop.

A) True
B) False

Correct Answer

verifed

verified

Benchmarking is the process of using the computer's clock to obtain run time information for an algorithm.

A) True
B) False

Correct Answer

verifed

verified

The time() function returns the amount of time a program has been running in seconds.

A) True
B) False

Correct Answer

verifed

verified

What type of algorithm is the following code? I = 0 While i < len(myList) - 1: MinIndex = i J = i + 1 While j < len(myList) : If myList[ j ] < myList[ minIndex ]: MinIndex = j J += 1 If minIndex != i: Swap(myList, minIndex, i) I += 1


A) binary search
B) bubble sort
C) sequential search
D) selection sort

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

Correct Answer

verifed

verified

How can the following algorithm be described? left = 0 Right = len(sortedLyst) - 1 While left <= right: Midpoint = (left + right) // 2 If target == sortedLyst[midpoint]: Return midpoint Elif target < sortedLyst[midpoint]: Right = midpoint - 1 Else: Left = midpoint + 1 Return -1


A) binary search
B) bubble sort
C) sequential search
D) selection sort

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

Correct Answer

verifed

verified

What type of algorithm is list indexing an example of?


A) constant-time
B) logarithmic-time
C) exponential-time
D) linear-time

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

Correct Answer

verifed

verified

An analysis of an algorithm's complexity divides its behavior into what three types of cases?


A) best case, worst case, average case
B) minimum case, maximum case, average case
C) linear case, quadratic case, logarithmic case
D) sequential case, exponential case, binary case

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

Correct Answer

verifed

verified

Showing 41 - 50 of 50

Related Exams

Show Answer