Quick Sort in 2 minutes | Explanation with animation | Coddict

preview_player
Показать описание
QuickSort is a sorting algorithm based on the Divide and Conquer algorithm that picks an element as a pivot and partitions the given array around the picked pivot by placing the pivot in its correct position in the sorted array.

Subscribe for more such content...
Рекомендации по теме
Комментарии
Автор

Code snippet (c++):

int partition(int arr[], int low, int high)
{
//choose the pivot

int pivot = arr[high];
//Index of smaller element and Indicate
//the right position of pivot found so far
int i = (low-1);

for(int j=low; j<=high; j++)
{
//If current element is smaller than the pivot
if(arr[j] < pivot)
{
//Increment index of smaller element
i++;
swap(arr[i], arr[j]);
}
}
swap(arr[i+1], arr[high]);
return (i+1);
}

// The Quicksort function implementation

void quickSort(int arr[], int low, int high)
{
// when low is less than high
if(low < high)
{
// pi is the partition return index of pivot

int pi = partition(arr, low, high);

//Recursion Call
//smaller element than pivot goes left and
//higher element goes right
quickSort(arr, low, pi-1);
quickSort(arr, pi+1, high);
}
}

coddict
Автор

It's so cool to see the algorithm in action 🎬 with 🎶

macolulu
Автор

What a playlist ❤
Crisp and to the point 🎉
Thanks a lot 😊

misstopper
Автор

This Is Absolutely Great Work 👏✨👍. This Is The Best and Fast Way To Understand Sorting and Other Algorithms.

You're Doing Amazing 😍 & Keep It Going 😀👍 Make More Full Video For Other DSA Algorithms and Sorting Techniques.

ankitkumar
Автор

Very easy to understand through Visualization..Superb

AMeghamala
Автор

Great animation!!!
Great and unique way of teaching!!!
👍👍👍

mustafasayyed
Автор

dammn impressive...plz make on other topics like merge and heap also

richaswaraj
Автор

please sir merge sort with this animation way with code

JbrDeveloper