retagged by
1,725 views
3 3 votes
3-way partitioning is a modification of quicksort that partitioned the elements into groups smaller than,equal to and larger than pivot. Only the group of smaller and larger elements need to be sorted. If there are N items and K unique value the running time of modified quick sort is-

(A) O(nlogk)

(B) O(klogn)

(C) O(nk)

(D) O(k^2)

1 Answer

2 2 votes

First check this link http://users.monash.edu/~lloyd/tildeAlgDS/Sort/Flag/

The DNF algorithm is a way to implement 2 way or 3 way or k-way partition quicksort, the question is that if there are K number of distinct elements in total N elements then what is complexity for sorting them?

Lets assume that number of  distinct elements  is 3 in N total elements, for simplicity assume they are 0 , 1 and 2 , so list would look like this after sorting is completed.

    00000....11111.....22222222

The DNF shows 3 way quicksort because there are 3 distinct integers in the list.

So question suggest that what is the complexity for sorting operation on list  if we were to perform K way quicksort on the list of the N integers having K distinct integers

Consider you have N objects and K colours and assuming that only constant of proportionality in time changes the complexity will be O(NK)

Key is in "Notes" section

The DNF algorithm can be extended to four, or even more colours but it grows more and more complex to write, and the constant of proportionality in its running time increases.

Answer C .

Best Of Luck.

edited by
Position:
Show:

Related questions

0 0 votes
0 0 answers
1.5k
1.5k views
0 0 votes
0 0 answers
463
463 views
Gurdeep Saini asked Nov 13, 2018
463 views
between hoare and loranto quicksort which give better cache performance ?we know that in hoare quicksort we move the pointer i,j in different direction but in loranto qui...
0 0 votes
1 1 answer
940
940 views
Vaishnavi01 asked Sep 21, 2018
940 views
True or False :In randomized quicksort , each key is involved in the same number of comparisons.
1 1 vote
1 answers 1 answer
825
825 views
dragonball asked Sep 27, 2017
825 views
Could anyone describe how the partitioning algorithm vary when the pivot is varied ?In Cormen , last element is taken as pivot . Suppose I took first element or middle e...