I had created code as per guidelines but code shows runtime exception, Please provide a solution to it.
Code: https://ide.codingblocks.com/s/233483
Randomized Quicksort, arithmetic exception
I have edited your code… Try to submit it now…
Thanks for it, but as ur trying to randomize array initially but actually don’t we need to randomize everytime? As Randomize quicksort means not making it hardcoded(If i am wrong please correct me). So which is better approach? to shuffle first or shuffle a single index with last everytime?
No…actually we require randomised quicksort to handle worst case as in case of reverse array elements given like 5 4 3 2 1 …
In this case the time complexity of quicksort will be O(n^2) …and to make tht case wrk in
O ( N log N) …we will first shuffle all the array elements and then apply quicksort algorithm on tht shuffled array…
1 Like