Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you are given a sequence or array of n real numbers: (a1, a2, . . . , an

ID: 3710752 • 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:

The given array of n real numbers are (a1, a2, a3, ........., an) .

The total ordering information in terms of permutation is 3, 2, 1. so, a3 <= a1 <= a2.

Hence the sorted form is (a3, a1, a2)

1. The total number of permutations available are  n! because there are ' n ' distinct elements in an array.

2. Here we are given the total ordering permutations, among those available permutations there will be one permutation in which all the elements of the array are sorted. so, we can slect that permutation without any comparison and the array wil be sorted in to one time.

3. If there is no total ordering permutation then we cannot sort the list without any comparision test. In this case we should know the the number of inversion required to see the array. Based on the permutations we can select the permutation which requires minimum inversions. Here inversion sort works well.

4. YES, the insersion sort method as discused above, in this the sorting will be running only the number or minimum number of passes which are required to sort the given array.

5. Its true, since n! is considered this will apply the merge sort or quick sort, as n^n according to String's approximation the e=given expression is equivalent to n log n.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote