recategorized
7,621 views
5 votes
5 votes

Suppose that the splits at every level of Quicksort are in proportion $1-\beta \text{ to } \beta$, where $0 < \beta \leq 0.5$ is a constant. The number of elements in an array is n. The maximum depth is approximately

  1. 0.5 $\beta$ Ig n
  2. 0.5 (1-$\beta$) Ig n
  3. -(Ig n)/(Ig $\beta$)
  4. -(Ig n)/Ig (1-$\beta$)
recategorized

1 Answer

5 votes
5 votes

Answer  D

Explanation

A maximum depth path  always takes the larger part of partition 

  • In question given that always β <=0.5
  • So maximum partition will be (1-β ) n

We have to find maximum depth d, means how many times quick sort loop will be executed!!

  • One iteration splits the number of elements from n to (β n ) and (1-β)n
  • So i iterations reduces the number of elements to β i n  and (1-β) i n .

At a leaf, there is just one remaining element,

In case of maximum depth path ( let maximum depth be d)

 (1-β)d n = 1

 (1-β)d  = 1/n

Take logarithm on both sides,

d log ( 1-β) = -log n

d = -log n/log ( 1-β)

  • Similarly we can find minimum depth d' = -log n/log β
edited by
Answer:

Related questions

1 votes
1 votes
2 answers
2
go_editor asked Jul 20, 2016
4,555 views
The efficient data structure to insert/delete a number in a stored set of number isQueueLinked listDoubly linked listBinary tree
1 votes
1 votes
1 answer
3
shivani2010 asked Jun 9, 2016
4,185 views
The min. number of nodes in a binary tree of depth d (root at level 0) is$(2^d + 1)$$(2^{(d+1)} - 1)$$d$$d + 1$
1 votes
1 votes
1 answer
4
go_editor asked Jul 20, 2016
1,824 views
The amortized time complexity to perform ____ operation(s) in Splay trees is O(Ig n)SearchSearch and InsertSearch and DeleteSearch, Insert and Delete