Worst-case of Quick Sort - Data Structure

Q.  Which of the following is the Worst-case of Quick Sort?
- Published on 26 Aug 15

a. O (n log n)
b. O (N2)
c. O (log n)
d. O (n2 / 4)

ANSWER: O (N2)
 

    Discussion

  • Nirja Shah   -Posted on 21 Nov 15
    - Worst case----------------------------O(N 2 )
    - Average case-------------------------O(N LOG N)
    - Best case------------------------------O(N LOG N)
    Quick sort algorithm is based on divide and conquer technique. It is a fast sorting technique. It is also known as partition exchange sort. In this technique we choose an element from the list of element and place it at the proper position means position of element in final sorted list. This element is called as pivot element. Rules for proper position of pivot is as follows.
    - All the element to the left of pivot should be less than or equal to the pivot element.
    - All the element to the right of pivot should be greater than or equal to the pivot element.
    After applying above two rules pivot element will be at proper position in the list.
    Any element of the list can be taken as pivot, but for simplicity the first element of the list should be chosen as pivot.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)