Sorting

22 flashcardsby Maria
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What are the three things that sorting routines are evaluated on
[A] speed
[B] memory overhead
[C] data sorted
2
The steps for the Heap Sort algorithm are as follows:
1. Put the items to be sorted in a [A] binary tree
2. Build the initial [B]
3. Repeatedly remove the [C] and [D]
[A] left balance
[B] heap
[C] root
[D] reheap or rebuild
3
Which sort has the highest memory overhead?
  • Binary Tree Sort
  • Heap Sort
  • Merge Sort
  • Quick Sort
4
Which sort recursively combines sorted sub-arrays?
  • Merge Sort
  • Binary Sort
  • Quick Sort
  • Heap Sort
5
Which sort recursively breaks the data set into two pieces based on a pivot value?
  • Quick Sort
  • Merge Sort
  • Heap Sort
  • Bubble Sort
6
Which sort requires a tree to be built which has a particular shape and order?
  • Heap Sort
  • Bubble Sort
  • Merge Sort
  • Quick Sort
7
Which sort is very simple to code and is the best for almost sorted data?
  • Bubble Sort
  • Quick Sort
  • Merge Sort
  • Heap Sort
8
When performing swaps within a sort method
  • Shallow copies are preferred over deep copies
  • Deep copies are preferred over shallow copies
  • There is not much difference in swapping deep or shallow copies
9
What is unique about the Binary Tree sort over the other sorts discussed in this chapter?
  • It doesn't perform swaps
  • It performs swaps
10
What is the theoretical minimum Big-Oh for comparison-based algorithms.
  • nlog2n
  • n^2
  • log2n
  • n
11
When creating a priority queue where the priorities are 1 - 4 where 1 is the highest priority:
1. This would be implemented with a (min, max) [A] heap
2. To insert to priority queue, place the new item to be sorted at the [B] of the array
3. The parent of an object at index 12 would be at index [C]
[A] min
[B] end
[C] 5
12
The algorithm for the Binary Search Sort requires that all items to be sorted be inserted into a Binary Search Tree. Then use the [A] traversal for ascending order and the [B] traversal for descending order.
[A] LNR
[B] RNL
13
The steps for the Merge Sort algorithm
1. Break the array into [A] sub-arrays
2. [B] each subarray
3. [C] the sorted subarrays together
4. Base case of the recursive algorithm is when the size of the sub-array is [D]
[A] 2
[B] sort
[C] merge
[D] 1
14
The speed of a sorting algorithm depends upon the number of [A] and the number of [B]
[A] comparisons
[B] swaps
15
Objects in an array to be sorted must be of the same class.
  • TRUE
  • FALSE
16
Sorting a chain of linked nodes is usually easier than sorting an array
  • TRUE
  • FALSE
17
Selection sort is efficient for large arrays.
  • TRUE
  • FALSE
18
Implementing the insertion sort for a linked chain of nodes is generally difficult.
  • TRUE
  • FALSE
19
The iterative merge sort algorithm is much simpler than the recursive algorithm
  • TRUE
  • FALSE
20
In quick sort, the partition places the pivot in the position that it will occupy in the final sorted array.
  • TRUE
  • FALSE
21
The radix sort restricts the data that it sorts on.
  • TRUE
  • FALSE
22
Divide and conquer algorithms can only be written recursively.
  • TRUE
  • FALSE
Study all 22 cards for free