Question: 3 VoodooSort Here s a simple recursive sorting algorithm that we will call VoodooSort: / / Sort array A [ ] between indices p and
VoodooSort
Heres a simple recursive sorting algorithm that we will call VoodooSort:
Sort array A between indices p and r inclusive.
VoodooSort A p r
Base Case: use InsertionSort
if r p
InsertionSortA p r ;
return ; add return statement to base case
Break the array into st quarter, nd quarter and second half
n r p ; number of items in Apr inclusive
q p n ; end of st quarter
q q n ; end of nd quarter
Sort the pieces
using VoodooSort, HeapSort and VoodooSort
VoodooSort A p q ;
HeapSort A q q ;
VoodooSort A q r ;
Merge the sorted arrays into sorted array
Merge A p q q ; Merge st & nd quarter
Merge A p q r ; Merge st & nd halves
return ;
In the following, you may assume without providing any proof that the worst case running times
of InsertionSort, HeapSort and Merge are Theta n
Theta n log n and Theta n respectively.
Write down a recurrence relation for the worst case running time of VoodooSort. Briefly
justify your answer.
Prove the best upper bound you can on the worst case running time of VoodooSort.
Prove the best lower bound you can on the worst case running time of VoodooSort.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
