Question

In: Computer Science

Please PROVE the following statement: The time complexity of any sorting algorithm that uses only comparisons...

Please PROVE the following statement: The time complexity of any sorting algorithm that uses only comparisons between elements is the following:

Ωn log n in the worst case. you need to prove this , if you can please type answer.

Solutions

Expert Solution

Analysis of different sorting technique

Time complexity Analysis –
We have discussed the best, average and worst case complexity of different sorting techniques with possible scenarios.

Comparison based sorting –
In comparison based sorting, elements of an array are compared with each other to find the sorted array.

  • Bubble sort and Insertion sort –
    Average and worst case time complexity: n^2
    Best case time complexity: n when array is already sorted.
    Worst case: when the array is reverse sorted.
  • Selection sort –
    Best, average and worst case time complexity: n^2 which is independent of distribution of data.
  • Merge sort –
    Best, average and worst case time complexity: nlogn which is independent of distribution of data.
  • Heap sort –
    Best, average and worst case time complexity: nlogn which is independent of distribution of data.
  • Quick sort –
    It is a divide and conquer approach with recurrence relation:
     T(n) = T(k) + T(n-k-1) + cn
    

    Worst case: when the array is sorted or reverse sorted, the partition algorithm divides the array in two subarrays with 0 and n-1 elements

Non-comparison based sorting –
In non-comparison based sorting, elements of array are not compared with each other to find the sorted array.

  • Radix sort –
    Best, average and worst case time complexity: nk where k is the maximum number of digits in elements of array.
  • Count sort –
    Best, average and worst case time complexity: n+k where k is the size of count array.
  • Bucket sort –
    Best and average time complexity: n+k where k is the number of buckets.
    Worst case time complexity: n^2 if all elements belong to same bucket.

Time and Space Complexity Comparison Table :

Sorting Algorithm Time Complexity Space Complexity
Best Case Average Case Worst Case Worst Case
Bubble Sort Ω(N) Θ(N2) O(N2) O(1)
Selection Sort Ω(N2) Θ(N2) O(N2) O(1)
Insertion Sort Ω(N) Θ(N2) O(N2) O(1)
Merge Sort Ω(N log N) Θ(N log N) O(N log N) O(N)
Heap Sort Ω(N log N) Θ(N log N) O(N log N) O(1)
Quick Sort Ω(N log N) Θ(N log N) O(N2) O(N log N)
Radix Sort Ω(N k) Θ(N k) O(N k) O(N + k)
Count Sort Ω(N + k) Θ(N + k) O(N + k) O(k)
Bucket Sort Ω(N + k) Θ(N + k) O(N2)

O(N)


Related Solutions

What is the time complexity of my algorithm? It uses an vector E that contains and...
What is the time complexity of my algorithm? It uses an vector E that contains and object made of a string and an integer. It takes an empty vector as parameter and returns the vector with the top three integers from the objects in E . void Trendtracker::top_three_trends(vector<string> &T) {    T.clear();    if (E.size() == 0) {        return;    }    if (E.size() == 1) {        T.push_back(E[0].hashtag);    }    else if (E.size() == 2)...
Is quicksort a stable sorting algorithm? If yes, prove it, if not, give an example
Is quicksort a stable sorting algorithm? If yes, prove it, if not, give an example
What is the auxiliary space and space complexity for a dynamic programming algorithm with time complexity...
What is the auxiliary space and space complexity for a dynamic programming algorithm with time complexity of O(n^2)? Justify.
What is the Average time complexity of sequential search algorithm in a linked list?
What is the Average time complexity of sequential search algorithm in a linked list?
Write a program, using any language you want, and any sorting algorithm discussed in this unit...
Write a program, using any language you want, and any sorting algorithm discussed in this unit to sort the following : 243, 1, 4, 6, 234, 33, 674, 32, 3333 Note: Can you write it in quick sort
Write a function in C that uses the Merge Sort sorting algorithm with arrays. The function...
Write a function in C that uses the Merge Sort sorting algorithm with arrays. The function must not be void and must output type int* i.e. it must take the form: int* merge_sort(int a[], int n) where a[ ] is the input matrix and n is the size of the matrix. You may use an auxiliary functions such as "merge." The returned array should be sorted using merge_sort and should not modify the array that was input (a[ ] ).
Give the asymptotic (“big-Oh”) running time complexity of the following algorithm, show all the work you...
Give the asymptotic (“big-Oh”) running time complexity of the following algorithm, show all the work you have done. Algorithm: ArrayMangle(A[ ], int n) Input: an array A, an integer n x = 0; for (i=0; i<=n-1; i++) { for (j=i; j<=n-1; j++) { x = x + A[j]; } for (k=0; k<= n-1; k++) { for (j=0; j< =n-1; j++) { x = x + A[j]*A[k]; } } }
Please explain what we mean by Time Complexity and Space Complexity. Please provide a short survey...
Please explain what we mean by Time Complexity and Space Complexity. Please provide a short survey of Complexity classes.
1. Mathematically analyze the given Recurrence Relation and find out the time complexity of the algorithm....
1. Mathematically analyze the given Recurrence Relation and find out the time complexity of the algorithm. T(n) = T(n-1)+1 , if n> 0 1 if n = 0
It's time to write a sorting algorithm! In this lab, you'll be writing Bubble Sort. Much...
It's time to write a sorting algorithm! In this lab, you'll be writing Bubble Sort. Much like the previous lab, you will be tasked with prompting the user for a list of values until the user enters 0 (you may use the same initializeVector that you wrote in the last lab). You will then write bubblesort which sorts the vector from smallest to largest. You will then call a function displayVector which displays the vector to the screen. Keep everything...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT