Suppose you are given a sequence or array of n real numbers: (a1, a2, . . . , an
ID: 3710924 • Letter: S
Question
Suppose you are given a sequence or array of n real numbers: (a1, a2, . . . , an). We are interested in sorting this list, and ideally sorting it as efficiently as possible / with minimal effort. We can summarize the total ordering information in terms of a permutation of the numbers 1 to n. For instance, given (a1, a2, a3), a total ordering permutation of 3, 1, 2 would tell us that a3 <= a1 <= a2, and therefore that the sorted form of the list would be (a3, a1, a2).
1) How many possible total ordering permutations are there?
2) Argue that if you know or are given the total ordering permutation, then you can sort the list without any additional comparisons or tests.
3) Argue that if you don’t know the total ordering permutation (or only know partial / incomplete information about it), you cannot sort the list without additional comparisons or tests.
4) Taking this view, argue that any sorting algorithm must do at least enough work to determine the total order permutation of the list.
5) If every element comparison (testing whether ai <= aj ) provides one bit of information, argue you need at least on the order of ln(n!) many tests/comparisons to sort the list.
Explanation / Answer
Answer:
1)
So in the array there are n separate rudiments this means that the numeral of total ordering permutations obtainable are n!
2)
If we are given with the total order permutation then within that variation there is one permutation in which all the elements of the array are sorted, just select that permutation and we are done, this will be done without any contrast and the array will be sorted in to (1) time.
3)
Yes, if this case we need to see the number of inversions required to see the array and based on whatever knowledge of the permutations we have we can select the variation which require minimal inversions; insertion sort can do best here.
4)
Yes, as stated above the introduction sort will be running only the figure or we say smallest amount number of passes which are required to sort the given array.
5)
True, this will be like applying Merge sort or quick sort in the array and since n! is careful as n^n according to String's estimate the e=given expression is equivalent to n log n.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.