Consider the array: "one" "ring" "to" "bring" "them" "all" "and" "in" "the" "darkness" "bind" "them" If these items are sorted into ascending order by the MSD Radix Sort algoirthm, which of the following is the resulting sequence? Sequence A: "to" "them" "them" "the" "ring" "one" "in" "darkness" "bring" "bind" "and" "all" Sequence B: "all" "and" "bind" "bring" "darkness" "in" "one" "ring" "the" "them" "them" "to" Sequence C: "in" "to" "all" "and" "one" "bind" "ring" "the" "them" "them" "bring" "darkness" Sequence D: "darkness" "bring" "them" "them" "the" "ring" "bind" "one" "and" "all" "to" "in"单项选择题
A
Sequence A
B
Sequence B
C
Sequence C
D
Sequence D
登录即可查看完整答案
我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。
类似问题
Question textRadix sort can be viewed as a sorting algorithm that uses stable counting sort as a subroutine. Radix sort breaks the input array into digits (in base b) and for each digit position, it calls a stable counting sort to sort the array based on that digit.Given the following input list [731, 58, 412, 999, 120, 305, 87, 640] which you are sorting using a radix sort with a base, b=3:The radix sort requires Answer 1 Question 2[input] iterations. The stable counting sort subroutine has a count-array of length Answer 2 Question 2[input].
Question textRecall the Counting Sort variant that is used as part of Radix sort. We provide it below, as given in the course notes: [table] 1 2 3 4 5 6 7 8 9 10 11 12 1314151617 | function RADIX_PASS(array[1..n], base, digit) // Digit counting counter[0..base-1] = [0,0,...] for i = 1 to n do counter[GET_DIGIT(array[i], base, digit)] += 1 // Position calculation position[0..base-1] = [1,0,...] for v = 1 to base−1 do position[v] = position[v − 1] + counter[v − 1] // Fill the temp array and swap // REPORT COUNTER AND POSITION HERE temp[1..n] = [0,0,...] for i = 1 to n do digit = GET_DIGIT(array[i],base,digit) temp[position[digit]] = array[i ] position[digit] += 1 swap(array, temp) [/table] Here, GET_DIGIT is 1-indexed, so GET_DIGIT(x, 10, 1) returns x % 10. Examples: GET_DIGIT(123, 10, 1) = 3, GET_DIGIT(123, 10, 2) = 2, GET_DIGIT(123, 10, 3) = 1 and GET_DIGIT(123, 10, 4) = 0 Note that some arrays are 1-indexed, and others are 0-indexed, since digits range from 0 to base-1.. Consider the following array of integers: [table] 15 | 872 | 572 | 4037 | 7836 | 4531 | 8981 | 26 [/table] Suppose we call RADIX_PASS(arr, 10, 3), where arr is the array above. Below, enter the values stored in counter and position as computed by the function AT LINE 11, as well as the final result for temp. You may find it useful to perform the counts and position calculations on working paper and copy onto the moodle box. [table] Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 counter | Answer 1 Question 5 | Answer 2 Question 5 | Answer 3 Question 5 | Answer 4 Question 5 | Answer 5 Question 5 | Answer 6 Question 5 | Answer 7 Question 5 | Answer 8 Question 5 | Answer 9 Question 5 | Answer 10 Question 5 position | Answer 11 Question 5 | Answer 12 Question 5 | Answer 13 Question 5 | Answer 14 Question 5 | Answer 15 Question 5 | Answer 16 Question 5 | Answer 17 Question 5 | Answer 18 Question 5 | Answer 19 Question 5 | Answer 20 Question 5 temp index | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | temp | Answer 21 Question 5 | Answer 22 Question 5 | Answer 23 Question 5 | Answer 24 Question 5 | Answer 25 Question 5 | Answer 26 Question 5 | Answer 27 Question 5 | Answer 28 Question 5 | | [/table]
R_sort_2 What is the worst-case time complexity of the Radix Sort algorithm for an array of n elements, where the maximum number of digits in any number is d?
zyBooks_18 Below is Radix Sort and its helper functions. What will RadixGetLength(17) evaluate to?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!