Question

In: Computer Science

Prove it's correct or wrong. A particular version of PARTITION runs in logarithmic time but produces...

Prove it's correct or wrong.

A particular version of PARTITION runs in logarithmic time but produces splits where all elements go to the same side of the pivot every time. QUICKSORT based on this PARTITION has the same worse-case running time as the standard version.

Solutions

Expert Solution

Hi,

---------------------------------------------------

Standard Quick Sort

1.if partiotion time is O(N) and produces splits where all elements go to the same side of the pivot every time. QUICKSORT based on this PARTITION has the same worse-case running time O(N2)

T(n)=T(N-1)+O(N)

= (N)+(N-1)+(N-2)+......+3+2+1

=(N)(N+1)/2

O(N2)

------------------------------------------

Modified Quick Sort ( when PARTITION runs in logarithmic time)

2.if partiotion time is O(logN) and produces splits where all elements go to the same side of the pivot every time. QUICKSORT based on this PARTITION has worst case running time O(NlogN) so QUICKSORT based on this PARTITION has not the same worse-case running time as the standard version.

T(n)=T(N-1)+O(logN)

=logN+log(N-1)+log(N-2)+log(N-3)+.......+ log3+log2+log0

=log(N*(N-1)*(N-3)*.....*3*2*1)

log(NN)

O(NlogN)

---------------------------------------------------------

Still if you have any doubt or need any kind of improvement, please let me know in comment section and if you like, Please upvote.

Thank You !


Related Solutions

prove it's correct or not. A particular version of MERGESORT breaks the array into three equal...
prove it's correct or not. A particular version of MERGESORT breaks the array into three equal parts, recursively sorts the first two parts, merges them, recursively sorts the last part, and merges it with the already merged parts one and two. This MERGESORT has the same worst-case running time as the standard version.
Is the following solution for the following question correct or not ? and if it's wrong...
Is the following solution for the following question correct or not ? and if it's wrong where is the mistake and how to correct it? Imagine that you own (250,000$) and you want to invest it in your dream plan. You have to consider two different alternatives. For each alternative, estimate the initial cost and annual cash flow details (operation and maintenance costs, raw material, salaries, overheads…etc.). Then compare these alternatives based on ROR criteria. Note: you don’t need to...
Prove that the partition problem is NP-complete by giving a polynomial time reduction of the subset-sum...
Prove that the partition problem is NP-complete by giving a polynomial time reduction of the subset-sum problem to the partition problem.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT