Can someone help me understand bubble sort.
Afficher commentaires plus anciens

I cant understand bubble sort(the code is given above). How is j and k used. In the for loop why is [ j = 1 : n-k ]. What does fewer tests on each pass mean. And I cant understand how temp is used to switch two numbers in x. And why is sorter reset to 0 after each for loop. Can someone explain this part by part? I only get the basic idea of how two numbers are compared and then replaced (or not) but how is it checked. Which two numbers are chosen first?
1 commentaire
Katlyn Rivera
le 17 Fév 2022
its actually swap not swop
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!