Computer Science Final Part 5

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

Suppose you have a phone number and need to find the address that it corresponds to. If there are 2,000,000 entries, how many do you expect to search in a printed phone directory before finding the address you are looking for?

Approximately 1,000,000 records.

The following code is an example of a ___ search. public static int search(int[] a, int v) { for (int i = 0; i < a.length; i++) { if (a[i] == v) { return i; } } return -1; }

linear

When does quicksort's worst-case run-time behavior occur? I when the data is randomly initialized in the array II when the data is in ascending order III when the data is in descending order

II and III

If an element is present in an array of length n, how many element visits, in the worst case, are necessary to find it using a linear search?

n

If an element is present in an array of length n, how many element visits, on average, are necessary to find it using a linear search?

n/2

A version of which sort algorithm is used in the sort method in the Java Arrays class?

quicksort

Which sort algorithm starts by partitioning the array and selecting a pivot element?

quicksort

In the worst case, a linear search locates a value in an array of length n in ____ steps.

O(n)

In the worst case, quicksort is a(n) ____ algorithm.

O(n^2)

Which sort algorithm is used in the sort method in the Java Arrays class when the array length is less than 7?

insertion sort


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

Online Personal Finance Final Review (in progress)

View Set

Chapter 2: The Chemical Basis of Life I QUESTIONS

View Set

Chapter 14 ( musculoskeletal imaging, breast, and superficial structures)

View Set