Home » 2.8.1 QuickSort Algorithm | Chia sẻ về chủ đề quick sort |

2.8.1 QuickSort Algorithm | Chia sẻ về chủ đề quick sort |

Hình như bạn đang muốn tìm hiểu sản phẩm nói về quick sort có phải không? Có đúng là bạn đang muốn tìm chủ đề 2.8.1 QuickSort Algorithm phải không? Nếu đúng như vậy thì mời bạn xem nó ngay tại đây.

2.8.1 QuickSort Algorithm | Xem thông tin về laptop tại đây.

[button color=”primary” size=”medium” link=”#” icon=”” target=”false” nofollow=”false”]XEM VIDEO BÊN DƯỚI[/button]

Ngoài xem những thông tin về laptop mới cập nhật này bạn có thể xem thêm nhiều thông tin hữu ích khác do https://soyncanvas.vn/ cung cấp tại đây nha.

Kiến thức liên quan đến bài viết quick sort.

Giải thích về thuật toán sắp xếp nhanh PATREON: Các khóa học về Udemy ================ Cấu trúc dữ liệu lập trình Java sử dụng C và C ++ Lập trình C ++.

Hình ảnh liên quan đếnnội dung 2.8.1 QuickSort Algorithm.

2.8.1  QuickSort Algorithm

2.8.1 QuickSort Algorithm

>> Ngoài xem bài viết này bạn có thể xem thêm nhiều Thông tin hay khác tại đây: Xem thêm thông tin hữu ích tại đây.

Từ khoá có liên quan đến đề tài quick sort.

#QuickSort #Algorithm.

algorithms,algorithm,Quicksort,qucik sort,quicksort algorithm,abdul bari,bari,gate.

2.8.1 QuickSort Algorithm.

quick sort.

Mong rằng những Thông tin về chủ đề quick sort này sẽ có giá trị cho bạn. Rất cảm ơn bạn đã theo dõi.

45 thoughts on “2.8.1 QuickSort Algorithm | Chia sẻ về chủ đề quick sort |”

  1. Hi Abdul.
    Im Korean who is learning computer science here in Denmark.
    I have actually watched more than 30 different quick sort tutorials, and can definitely say your the best.
    it helps A Lot, thank you so much. 😘😘😘

  2. If you are using Java language to convert the pseudocode to functioning code, hope this will help. I am also open for corrections and optimization approach in what I have coded 🙂

    public class Main {

    public static void main(String[] args) {

    int[] ch = {999,5353,2,56,2,7,7,1,2,6,2,2,2,2,2,65,8,5};

    quickSort(ch, 0, ch.length);

    for (int a : ch) {

    System.out.print(a + " ");

    }

    System.out.println();

    }

    public static void quickSort(int[] qs, int low, int high) {

    if (low < high) {

    int j = partition(qs, low, high);

    quickSort(qs, low, j);

    quickSort(qs, j + 1, high);

    }

    return;

    }

    public static int partition(int[] part, int low, int high) {

    int pivot = part[low];

    int i = low, j = high;

    while (i < j) {

    do {

    i++;

    if (i == part.length) {

    break;

    }

    } while (part[i] <= pivot);

    do {

    j–;

    } while (part[j] > pivot);

    if (i < j) {

    int temp;

    temp = part[i];

    part[i] = part[j];

    part[j] = temp;

    }

    }

    int temp;

    temp = part[low];

    part[low] = part[j];

    part[j] = temp;

    return j;

    }

    }

  3. Abdul Bari sir, you are extremely good at teaching hard concepts in a way that is easy for us to understand! Thank you so much for uploading these wonderful videos of Algorithms and Data Structures!

  4. Hey Abdul Bari! Excellent video; explanation is very clear and easy to follow. I just have one piece of feedback: I was wondering if you could edit the closed captions for this video? I have noticed some instances where the auto-generated captions display the wrong words (for example, around the 6-minute mark, by volt instead of pivot) and this might make it more difficult for the folks globally who rely on closed captions to understand the videos. Thank you very much and have a great day!

  5. //QUICK SORT
    //if any corrections then please let me know

    #include <stdio.h>

    #include <stdlib.h>

    int a[10];

    void swap(int *a, int *b)

    {

    int temp;

    temp = *a;

    *a = *b;

    *b = temp;

    }

    int partition(int l, int h)

    {

    int pivot, i, j;

    pivot = a[l];

    i = l;

    j = h;

    while(i < j)

    {

    do

    {

    i++;

    }while(a[i] <= pivot);

    do

    {

    j–;

    }while(a[j] > pivot);

    if(i < j)

    swap(&a[i], &a[j]);

    }

    swap(&a[l], &a[j]);

    return j;

    }

    void quicksort(int l, int h)

    {

    int j;

    if(l < h) //minimum 2 elements

    {

    j = partition(l, h);

    quicksort(l, j);

    quicksort(j+1, h);

    }

    }

    int main()

    {

    int n;

    printf("Enter the number of elements: ");

    scanf("%d", &n);

    printf("Enter the elements: ");

    for(int i = 0; i < n; i++)

    scanf("%d", &a[i]);

    a[n] = 9999; //last element = infinity

    quicksort(0, n+1);

    printf("The elements: ");

    for(int i = 0; i < n; i++)

    printf("%d ", a[i]);

    }

  6. Looks like a small correction required in the pseudo code. Simple java program as per the instructions provided by Bari Sir! I may be wrong, Let us for wait for experts advise to rewrite the logic!

    import java.util.Arrays;

    public class QuickSortDemo2 {

    public void quickSort(int low, int high, int [] arr) {
    if (low < high) {
    int pivotPos = partition(low, high, arr);
    quickSort(low, pivotPos, arr);
    quickSort(pivotPos + 1, high, arr);
    }
    }

    public int partition(int low, int high, int[] arr) {
    int i = low, j = high;
    int pivot = arr[low];
    while (i < j) {
    do {
    i++;
    } while (high != i && arr[i] <= pivot); //(high != i, correction required here)

    do {
    j–;
    } while (arr[j] > pivot);

    if (i < j) {
    swap(i, j, arr);
    }
    }
    swap(low, j, arr);
    return j;
    }

    public void swap(int i, int j, int []arr) {
    int temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
    System.out.println("After swap "+ Arrays.toString(arr));
    }

    public static void main(String []args) {
    QuickSortDemo2 demo = new QuickSortDemo2();
    int[] arr = { 12, 3,6 ,5,2,45,25,1,100,2,999};
    demo.quickSort(0, ((arr.length)), arr);
    System.out.println("Final array "+ Arrays.toString(arr));
    }
    }

  7. Mr Bari, you really are such a talented teacher and individual. I really can't express my gratitude enough for all of these videos. You really make hard concepts easy to digest and I really thank you for that. I have both of your courses C++ and C++ DSA, as Im taking it to supplement my university lectures.

  8. Sir I think in pseudo code there should be if(A(I)【pivot && A(j)】pivot) then swapA(I),A(j) as we are not swapping by comparing simply indexes.if that would be the case the it will swap all till while loop is running.

  9. One issue of this code. if A[0] is the biggest number, then while (A[i]<=Pivot) will always be true, so go into infinite loop. So we need to change to while(i<h && A[i]<=pivot)

  10. The ease with which you explain the algorithm is just mesmerizing, you make the topic look so simple to understand even if its very complicated. Please do make more videos. It's really very helpful.

  11. When I came to college I saw this video to pass my University Exams then, I again watched it before my placement Exams, now I am again watching it before using it in actual Software Code.

Leave a Reply

Your email address will not be published. Required fields are marked *