Sorts Lab(Chunk C)
Which is the sorted list for the array char check[] = {'A', 'b', 'C', 'a', 'Z', 'x'}? Hint: Keep in mind the ASCII values for characters
A,C,Z,a,b,x --capitals are smaller in ASCII then small numbers
( blank )Sort is a sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly picks the proper next value to move from the unsorted part to the end of the sorted part.
Selection --selection selects best from unsorted
Merge sort def
The merge sort algorithm treats the input as two halves, recursively sorts each half, and then merges the sorted halves to produce a sorted list
Sorting algorithms ______ elements in a list, comparing their values to modify Choice 1 of 4:modify Choice 2 of 4:delete Choice 3 of 4:swap Choice 4 of 4:insert
swap
If the list {29, 18, 45, 7, 16} is sorted in ascending order using selection sort, what will be the value of the 0th element after the first pass over the outer loop (i = 0)? Choice 1 of 4:29 Choice 2 of 4:45 Choice 3 of 4:16 Choice 4 of 4:7
7
How many recursive partitioning levels are required for a list of 256 elements in merge sort?
8
Using the Big-O runtime complexity for insertion sort, how many times longer will sorting a list of n=15 elements take compared to sorting a list of n=5 elements?
9
Identify the sorted list for A={ADRIAN, ABBEY, ADRIA, ABBIE}.
{ABBEY, ABBIE, ADRIA, ADRIAN
Given the following list of sorted elements, how many elements of the list will be checked to find 25 using the binary search? {12, 13, 15, 20, 23, 24, 25, 36, 40}
2
If a list has 1024 elements and if each comparison takes 2 µs, then what is the longest possible runtime for binary search on this list?
22
Given the list {12, 30, 40, 0, 47}, how many swaps will occur during the outer loop execution (i = 3) of insertion sort?
3
Given a list of numbers {17, 3, 44, 6, 9}, identify the list after sorting in ascending order.
3,6,9,17,44
In the worst case, assuming each odd comparison (comparing two odd numbers) takes 2 µs and each even (comparing two even numbers) comparison takes 1 µs, how long will an insertion sort algorithm take to sort a list of 6 elements?
30 us
Given an array of numbers [73, 42, 5, 28, 93, 34, 17, 66] where lowIndex = 2 and highIndex = 6, what is the midpoint that will be used by Quicksort? Choice 1 of 4:2 Choice 2 of 4:3 Choice 3 of 4:4 Choice 4 of 4:8
4
Given the list [23, 6, 19, 92], lowIndex = 0, and highIndex = 3, what are the contents of the low partition? Assume quicksort always chooses the smallest element as the pivot.
6
Using the big O bound on selection sort, how many times longer will sorting a list of n=40 elements take compared to a list of n=5 elements?
64: -40^2/5^2 --1600/25 --which equals 64
If the list {3, 9, 7, 18, 1} is being sorted in ascending order using selection sort, what will be the list after completing the second outer loop iteration? Choice 1 of 4:{1, 9, 7, 18, 3} Choice 2 of 4:{1, 3, 7, 18, 9} Choice 3 of 4:{1, 3, 7, 9, 18} Choice 4 of 4:{1, 3, 9, 18, 7}
choice 2
Given an array of numbers [73, 42, 5, 28, 93, 34, 17, 66] where lowIndex = 1 and highIndex = 4, what is the pivot value that will be used by Quicksort as presented in the text and lecture? Choice 1 of 4:34 Choice 2 of 4:5 Choice 3 of 4:42 Choice 4 of 4:93
choice 2:5
For the given lists, which option is correct? {60, 70, 85, 14, 90, 100}, {50, 60, 70, 79, 84, 100}, {20, 21, 22, 19, 18, 17} Choice 1 of 4:Sorted, unsorted, nearly sorted Choice 2 of 4:Unsorted, sorted, nearly sorted Choice 3 of 4:Nearly sorted, sorted, unsorted Choice 4 of 4:Unsorted, nearly sorted, sorted
choice 3
Which of the following is a sorted list? Choice 1 of 4:{ALISHA, ALISSON, ALISON, ALIYA} Choice 2 of 4:{154, 125, 652, 700} Choice 3 of 4:{1, 2, 3, 0} Choice 4 of 4:{Z, X, B, A}
choice 4 descending order
Which is not necessarily true of Quicksort? Which is not necessarily true of Quicksort? Choice 1 of 4:Quicksort repeatedly partitions the input into low and high parts (each part unsorted). Choice 2 of 4:Quicksort chooses a pivot to divide the data into low and high parts. Choice 3 of 4:Quicksort divides the array into two parts to partition the input. Choice 4 of 4:Quicksort uses the midpoint to divide the data into low and high parts.
choice 4:Quicksort uses the midpoint to divide the data into low and high parts. -pivot can be any value
Which option of worst case runtimes below correspond to Selection Sort, Insertion Sort, Quicksort, Mergesort, and Radix Sort respectively?
selection :O(n^2), insertion: O(n^2), quicksort:O(n^2), mergesort: O(nlog(n)), radix sort: O(nk)
In a list {25, 31, 14, 58, 66, 47, 98, 40}, where i = 2 and k = 6, determine index j and the values stored in the left partition and the right partition for merge sort?
j = 4, Left Partition = {14, 58, 66} and Right partition = {47, 98}
When running the quicksort partition method (as presented in the text and lecture) on the array [73, 42, 5, 28, 93, 34, 17, 66] where lowIndex = 0 and highIndex = 3, will the partitions be sorted?
no
SelectionSort -- XXX for (i = 0; i < XXX; ++i) {
numSize-1