Can someone help me understand bubble sort.
Show older comments

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 Comment
Katlyn Rivera
on 17 Feb 2022
its actually swap not swop
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!