div-bargali / Data-Structures-and-Algorithms

Data Structures and Algorithms implemented In Python, C, C++, Java or any other languages. Aimed to help strengthen the concepts of DSA. Give a Star 🌟 if it helps you.
MIT License
270 stars 396 forks source link

Created a more efficient version of Quick sort called randomized quic… #883

Closed Amrit-Raj-Nits closed 2 years ago

Amrit-Raj-Nits commented 2 years ago

…k sort

The code for randomized quicksort uses a rand() function which generates a random number between a given range. We choose a random index and swap the element at that index with the last element. After this step, we make the new last element a pivot. Generated Output for the code is as follows:-

Array before sorting:- 10 7 8 9 5 1 5 Array after sorting:- 1 5 5 7 8 9 10

Pull Request Template

What have you Changed(must)

Write here what you have changed in codebase

Issue no.(must) -

Pr will be closed and marked as spam. If issue number not found or issue was assigned to someone else. Marking as spam can block your account from HacktoberFest.

Self Check(Tick After Making pull Request)

README - How to Contribute