CSC 345

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of these is the best definition for a stable sorting algorithm? A. An algorithm that always gives the right answer B. An algorithm that does not change the relative ordering of records with identical keys C. An algorithm that is as fast as the best one known D. An algorithm that always gives the same order for duplicate keys from run to run

B. An algorithm that does not change the relative ordering of records with identical keys

Binsort's time complexity depends on the initial ordering of the keys in the input array A. True B. False

B. False

In shellsort, it is illegal to have an increment of 5 when the array size is 14. A. True B. False

B. False

Quicksort (as shown in class and the book) is a stable sorting algorithm. Recall that a stable sorting algorithm maintains the relative order of records with equal keys. A. True B. False

B. False

If I is the number of inversions in an input array of n records, then Insertion Sort will require how many swaps? A. n^2/2 B. I C. I - n

B. I

Is the following a legal series of increments when running Shellsort on an array of 16 values? A. Yes B. No

B. No

Is the following a legal series of increments when running Shellsort on an array of 16-values? > 8, 4, 2, 3, 1 A. Yes B. No

B. No

Which of the following is true of open hashing? A. The algorithm running time is determined by probes of different table cells until an empty one is found B. Records are stored on a list associated with a slot in the hash table C. All records are stored directly within the hash table

B. Records are stored on a list associated with a slot in the hash table

When is Bubble Sort a good choice for sorting an array? A. The array has only a few items out of place B. There is no situation where Bubble Sort is the best choice over all the others we will study C. Each component of the array requires a small amount of memory D. Each component of the array requires a large amount of memory

B. There is no situation where Bubble Sort is the best choice over all the others we will study

If you double the size of the hash table, can you keep using the same hash function? A. Yes, it works fine since the table size does not matter to the hash function B. Yes, but you will not hash to the new cells C. No, the hash function would now generate illegal values

B. Yes, but you will not hash to the new cells

Mergesort works by splitting a list of n numbers in half, then sorting each half recursively, and finally merging the two halves. Which of the following list implementations would allow Mergesort to work in O(n log(n)) time. A. A singly linked list B. A double linked list C. An array D. (1), (2), and (3) E. (3) only F. (1) and (2) only G. (1) only H. (2) only I. None of them J. (2) and (3) only

D. (1), (2), and (3)

Consider what happens if someone accidentally calls sort on a file that is already sorted. Which of the following sorting methods will be the most efficient if the input is already in sorted order. A. Bubble Sort B. Mergesort C. Selection Sort D. Insertion Sort

D. Insertion Sort

A disadvantage of Heapsort is: A. None of these answers B. It needs a lot of auxiliary storage C. Its average case running time is Ө(n2) D. It is not stable (i.e. records with equal keys might not remain in the same order after sorting)

D. It is not stable (i.e. records with equal keys might not remain in the same order after sorting)

An open hashing table has an array size of 99. What is the maximum number of records that can be stored in the table? A. 99 B. 49 C. 98 D. There is no maximum

D. There is no maximum

What is the running time for Insertion Sort when the input array has values that are in reverse order? A. Ө(n logn) B. Ө(logn) C. Ө(n^2) D. Ө(n)

C. Ө(n^2)

What is the worst-case cost for Quicksort to sort an array of n elements? A. Ө(logn) B. Ө(logn) C. Ө(n^2) D. Ө (n)

C. Ө(n^2)

Hashing is good for which queries? A. Exact match queries B. Range queries C. Find the maximum key value D. All of these E. None of these

A. Exact match queries

What is the most complicated part of the Mergesort algorithm? A. Merging the sorted halves back together B. Achieving the base case C. Finding the midpoint D. Partitioning the array

A. Merging the sorted halves back together

Consider an array A of n records each with a unique key value, and ARthe same array in reverse order. ANy given pair of records must be an inversion in exactly one of A or AR. A. True B. False

A. True

In Shellsort, how are the sublists sorted? A. Using Insertion Sort because Shellsort generally makes each subarray reasonably close to sorted B. Using Quicksort, because this is generally the fastest sort C. Using Shellsort since this is a recursive algorithm D. Using bubble sort since that is the most appropriate sort in this situation E. Using any sort that you like, it doesn't matter so long as they are sorted

A. Using Insertion Sort because Shellsort generally makes each subarray reasonably close to sorted

You must merge two sorted lists of size m and n, respectively. The number of comparisons needed in the worst case by the merge algorithm will be A. m + n - 1 B. m * n C. max(m, n) D. min(m, n)

A. m + n - 1

The order of the input records has what impact on the number of comparisons required by Selection Sort (as presented in the books and class)? A. There is a constant factor difference B. There is a big difference, the asymptotic running time can change C. None

C. None

When implementing Insertion Sort, a binary search could be used to locate the position within the first i-1 records of the array into which record i should be inserted. Using binary search will: A. Speed up the asymptotic running time because to position to insert will be found in O(log(i)) time B. None of these answers is correct C. Not speed up the asymptotic running time because shifting the records to make room for the insert will require O(i) time. D. Speed up the asymptotic running time because shifting the records to make room for the insert will require O(i) time.

C. Not speed up the asymptotic running time because shifting the records to make room for the insert will require O(i) time.

Which of these is a traditional measure for the cost of a sorting algorithm? A.The memory size B. The number of records C. The number of comparisons D. The amount by which the values are out of order

C. The number of comparisons

Which of these is a traditional measure for the cost of a sorting algorithm A. The amount by which the values are out of order B. The number of records C. The number of swaps D. The memory size

C. The number of swaps

What is the best-case time for Insertion sort to sort an array of n records? A. Ө(n logn) B. Ө(logn) C. Ө(n) D. Ө(n2)

C. Ө(n)

What is the average-case time for Selection Sort to sort an array of n records? A. Ө(n) B. Ө(n logn) C. Ө(n^2) D. Ө(logn)

C. Ө(n^2)


Conjuntos de estudio relacionados

Oaks Quiz Questions Chapters 1, 4, 5, 10 , 11, 6, 7, 8, 9, 2, 3, 12, 13, 15

View Set

Honors World History I chp 11 practice test

View Set

Patho Ch 39 Disorders of Male GU

View Set

Chapter 43: Disorders of the Male Reproductive System

View Set

Entrepreneurship small business Exam 1 (ch.3)

View Set

Lecture Week 4 - Hand and UE Injuries

View Set

Health and Life Insurance - Life insurance Basic

View Set

A.2.5 Pro Domain 5: Audit and Security Assessment

View Set