edited by
15,247 views
11 11 votes

A machine needs a minimum of $100$ sec to sort $1000$ names by quick sort. The minimum time needed to sort $100$ names will be approximately

  1. $50.2$ sec
  2. $6.7$ sec
  3. $72.7$ sec
  4. $11.2$ sec
 
 
 

3 Answers

Best answer
28 28 votes
Running time of quick sort = c n lg n

For n = 1000, we get

100 = c * 1000 * lg 1000 => c = 0.01

So, for n = 100, we get running time = 0.01 * 100 * lg 100 = 6.7
selected by
15 15 votes
min no of comparison for quick sort = nlogn

so to sort 1000 names 1000*3 ie 3000 comparisons are needed.

For 3000 comparisons we need 100s , thus for 1 comparison we need 0.033s

To sort 100 names we need 200 comparisons thus time needed is 0.033*200 s = 6.67 s
2 2 votes
TC of Quick Sort = O(nlogn) = c.nlogn (base = 2)

For, n = 1000,
TC = 100 sec = c (1000 x log1000)
         100 sec = c (1000 x log1024) // log1000 ≈ log1024
         100 sec = c (1000 x 10)
                    c = 0.01 sec

For, n = 100
TC = c (100 x log100)
      = 0.01 (100 x log100) sec
      = 0.01 (100 x log128) sec // log100 ≈ log128
      = 0.01 (100 x 7) sec
      = 7 sec ≈ 6.7 sec

So, option B is correct
Answer:
Position:
Show:

Related questions

7 7 votes
5 answers 5 answers
8.8k
8.8k views
shivanisrivarshini asked Jun 5, 2016
8,820 views
The number of spanning trees for a complete graph with seven vertices is$2^5$$7^5$$3^5$$2^{2 \times 5}$
73 73 votes
5 answers 5 answers
26.9k
26.9k views
Anu asked Jun 1, 2015
26,880 views
A hash table with ten buckets with one slot per bucket is shown in the following figure. The symbols $S1$ to $S7$ initially entered using a hashing function with linear p...
67 67 votes
3 answers 3 answers
33.5k
33.5k views
Kathleen asked Sep 23, 2014
33,455 views
If one uses straight two-way merge sort algorithm to sort the following elements in ascending order: $20, \ 47, \ 15, \ 8, \ 9, \ 4, \ 40, \ 30, \ 12, \ 17$then the o...
40 40 votes
7 answers 7 answers
28.2k
28.2k views
Kathleen asked Sep 18, 2014
28,216 views
The time complexity of the following C function is (assume $n 0$)int recursive (int n) { if(n == 1) return (1); else return (recursive (n-1) + recursive (n-1)); }$O(n)$$...