Data Structures Quiz 4

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

What is an external sorting algorithm?

A. Algorithm that uses tape or disk during the sort.

Merge sort uses

A. Divide and conquer

A Selection sort algorithm sorts the list by which method?

A. Finding the smallest element in the list and moving this to the beginning of the unsorted list.

A selection sort algorithm sorts the list by which method?

A. Finding the smallest element in the list and moving this to the beginning of the unsorted list.

Which algorithm would work best to sort data as it arrives, one piece at a time, perhaps from a network?

A. Insertion sort

What is an in-place sorting algorithm?

A. It needs O(1) or O(logn) memory to create auxiliary locations.

What is the advantage of selection of sort over other sorting techniques?

A. It requires no additional storage space.

Merge sort works on the principle of divide-and-conquer

A. True

On average, a sequential search algorithm would make N/2 number of comparisons for a list size of N.

A. True

The heap sort algorithm begins by converting the list into a heap, then sorting.

A. True

The insertion sort algorithm improves on the selection sort method by reducing the number of comparisons.

A. True

The merge sort algorithm differs from the quick sort only in how it partitions the list, which is to create two nearly equal sub lists.

A. True

The quick sort algorithm divides the list into two sub lists, then sorts each sub lists, and then combines both sub lists.

A. True

What is the key used in a search algorithm?

A. Used in operations such as sorting, inserting, and deleting.

Select the appropriate code that performs bubble sort.

A.

Select the appropriate code that performs selection sort.

A.

What are the correct intermediate steps of the following data set when it is being sorted with the Insertion sort? 15, 20, 10, 18

A. 15, 20, 10, 18 10, 15, 20, 18 10, 15, 18, 20 10, 15, 18, 20

The given array is arr = {1, 2, 4, 3}. Bubble sort is used to set the array elements. How many iterations will be down to sort the array?

A. 4

Consider an array of elements arr[5] = {5, 4, 3, 2, 1}, what are the steps of insertions done while doing insertion sort in the array

A. 4 5 3 2 1 3 4 5 2 1 2 3 4 5 1 1 2 3 4 5

The given array is arr = {3, 4, 5, 2, 1}. The number of iterations in bubble sort and selection sort respectively are

A. 5 and 4.

Consider the following lists of partially sorted numbers. The double bars represent the sort marker. How many comparisons and swaps are needed to sort the next number using the insertion sort? [1 3 4 8 9 || 5]

B. 3 comparisons, 2 swaps

If no one uses straight two-way merge sort algorithm to sort the following elements in ascending order: 20, 47, 15, 8, 9, 4, 40, 30, 12, 17

B. 8, 15, 20, 47, 4, 9, 30, 40, 12, 17

A binary search algorithm can bet best described as what?

B. A divide and conquer technique.

What is an internal sorting algorithm?

B. Algorithm that uses main memory during the sort.

Which search algorithm is best for a large list?

B. Binary Search

What is the disadvantage of selection sort?

B. It is not scalable.

You must sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?

B. Merge sort.

Consider a situation where swap operation is very costly. Which s the following sorting algorithms should be preferred so that the number of swap operations are minimized in general?

B. Selection Sort

What operation does the Insertion Sort use to move numbers from the unsorted section to the sorted section of the list?

B. Swapping

Considering the following lists of partially sorted numbers. The double bars represent the sort marker. How many comparisons and swaps are needed to sort the next number using the insertion sort? [1 3 4 5 8 9 || 2}

C. 6 comparisons, 5 swaps

Searching and sorting algorithms are best implemented with which data structure?

C. Both above

The purpose of the bubble sorting algorithm is what?

C. Both choices above.

The following best describes which algorithm? The elements are compared and swapped if the first is found to be greater than the second.

C. Bubble sorting algorithm

What is the advantage of bubble sort over other sorting techniques?

C. Detects whether the input is already sorted.

In the following scenarios, when will you use selection sort?

C. Large values need to be sorted with small keys.

What is the best sorting algorithm to use for the elements in array are more than 1 million in general?

C. Quick sort.

The given array is arr = {1, 2, 3, 4, 5}. (Bubble sort is implemented with a flag variable). The number of iterations in selection sort and bubble sort respectively are

D. 4 and 1

Which of the following is not true about comparison-based sorting algorithms?

D. Heap Sort is not a comparison-based sorting algorithms.

The below diagram represents what type of sorting algorithm?

D. Merge Sort


Conjuntos de estudio relacionados

Injury Care and Prevention Final

View Set

Biology Chapter 27- Evolution of Life

View Set

Pharm Chapter 46: Antineoplastic Drugs Part 2

View Set