Home » Algorithms: Bubble Sort | Thông tin về chủ đề bubble sort |

Algorithms: Bubble Sort | Thông tin về chủ đề bubble sort |

Phải chăng bạn đang cần tìm sản phẩm về bubble sort có phải không? Phải chăng bạn đang muốn tìm chủ đề Algorithms: Bubble Sort phải không? Nếu đúng như vậy thì mời bạn xem nó ngay tại đây.

Algorithms: Bubble Sort | 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 nội dung liên quan khác do soyncanvas.vn cung cấp tại đây nha.

Kiến thức liên quan đến từ khoá bubble sort.

Tìm hiểu kiến ​​thức cơ bản về thuật toán sắp xếp bong bóng. Video này là một phần của Hướng dẫn Phỏng vấn Cracking The Coding của HackerRank với Gayle Laakmann McDowell.

Hình ảnh liên quan đếnchuyên mục Algorithms: Bubble Sort.

Algorithms: Bubble Sort

Algorithms: Bubble Sort

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

Tag có liên quan đến đề tài bubble sort.

#Algorithms #Bubble #Sort.

[vid_tags].

Algorithms: Bubble Sort.

bubble sort.

Với những Kiến thức về chủ đề bubble sort này sẽ mang lại kiến thức cho bạn. Rất cảm ơn bạn đã theo dõi.

41 thoughts on “Algorithms: Bubble Sort | Thông tin về chủ đề bubble sort |”

  1. def bubble_sort(arr):
    last = len(arr)-1
    while last!=0:
    for i in range(last):
    if arr[i] > arr[i+1]:
    temp = arr[i]
    arr[i] = arr[i+1]
    arr[i+1] = temp
    last = last-1
    return arr

    Any pitfalls in my code?

  2. Sorry but this logic is not correct. Let's take this input { 64, 34, 25, 12, 22, 11, 90 }. Before end of first iteration when elements are like below { 34, 25, 12, 22, 11, 64, 90 } in next for loop it will compare 64>90 will return false and isSorted = true; and it will never update it to false will not run second iteration and final result will be { 34, 25, 12, 22, 11, 64, 90 } below logic should work

    private void bubbleSort(int[] arr) {

    int lastUnSorted = arr.length-1;

    while(lastUnSorted>=0) {

    for(int i=0;i<lastUnSorted;i++) {

    if(arr[i]>arr[i+1]) {

    int temp = arr[i];

    arr[i] = arr[i+1];

    arr[i+1] = temp;

    }

    }

    lastUnSorted–;

    }

    }

  3. there is something wrong with the program,so I removed the boolean value and modified while loop as "while(lastUnsort >= 0)" followed by inner for loop, lastUnsort- – ;

  4. The while(!sorted) is good if the array is already sorted. But for some beginners, this maybe some what confusing. Just for someone is not 100% getting the explanation I have written the following, for these two loops, it is more appearing why time complexity for Bubble sort is O(N^2)
    public static void bubblesort(int[] array){
    for(int i=0; i < array.length -1; i++) {
    for (int j = 0; j < array.length – 1 -i; j++) {
    if (array[j] > array[j + 1]) {
    swap(array, j, j+1);
    }
    }
    }
    }

  5. !!!!!!!!!!!!!!!!!!!!!!!!!!!!THIS CODE DOESN'T WORK!!!!!!!!!!!!!!!!!
    array[i] > array[i++]; value of "i" is same both sides, hence this always fails..

  6. I remember this from high school — still a great presentation on the topic.

    Personally, I'm tired of the pretense that employers aren't that concerned with language knowledge but are deeply concerned with algorithms and problem-solving. The more experience I get with looking for real jobs the more I find its the opposite — they don't care if you could ace a college algorithms test, nor do they care if you are skilled at developing your own algorithms and systems. No, they want someone already experience in some specific domain of programming and with expertise on specific libraries / frameworks / technologies; they want "spring and hibernate" or "Django, along with SQL, HTML, CSS, and JavaScript." They may also ask for a bunch of other things that aren't important to them, but toward the top you see something like this that is non-negotiable. Funny thing is, a talent dev who has good problem solving and self-teaching skills could learn what they need, but they don't care. All the videos on YouTube pushing algorithms, data structures, design patterns, "problem-solving," etc., are red herrings luring aspiring professional away from what they really need to learn to get that first job and make real progress toward starting a career. If you've bothered to read all this consider it your reality check for the day.

     Perhaps (?) it's different for tech giants in areas with large tech industries, lots of local talent, and large teams capable of mentoring new employees — but the vast majority of business seeking devs are not like this at all.

  7. When you "swap" an array, isnt it passing by reference, meaning that it only swaps that array on that line and it doesn't remember the "new sorted" array while it continues in the loop…?

  8. This is the first time I have seen someone improve the efficiency of bubble-sort. Anyone who is really really new may not understand on the first go but this video is really well made.

  9. But doesn't the performance of this implementation depend heavily upon how isSorted is defined? Or if it is a built-in function? Considering that it is not and you write it out, then this will be a terrible algo because you check if the array is sorted or not each time you iterate through the loop! Can we do better than this?

  10. Very nicely done. Gayle does an outstanding job here. I would like to see a similar presentation using C programming code. Thank you for providing this.

  11. Straight after the while (!isSorted) condition, the next line is isSorted = true; so wouldn't the code just jump out there and never go through the following if statement? or will it complete the if statement first and then check whether to restart again?

  12. I really didn't get why everyone is saying bubble sort complexity is O(n^2),
    Actually, if you consider the inner loop is getting shorter each time the outer loop loops,
    You will find the execution complexity is O(n*(n-1)/2)

  13. 😤😑😑😑😑😓😓👹👿👹👹👹😮😮😓👐👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾👳🏾🙅🏿‍♂️

  14. 00:55 it should be O(n) space, because we've got one array of n elements. Or she just thought ok additional space that we need except for the array holding n elements is 0 so its constant => O(1) …

Leave a Reply

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