© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
avoidenz

I'm having trouble understanding Bubble Sort.

So the whole schtick about a bubble algorithm is that it compares a number with the number next to it, and then sorts it based on the value of the numbers. So if an array were to look like this:

int[] numbers = { 9, 7 };

It would compare 9 to 7, see that 9 is bigger than 7 and switch them.

In my example the code should go like this if i understand it correctly:

int i = 0 and the length of the array - 1 equals 6. So i then becomes 1 and the for loop is started.

int j = 0 too and the length of the array - (1 + 1 (which is i)) equals 5. int j becomes 1 and the the for loop is started.

Now here is where you lose me with this one.

What is numbers[ j ]? I think i missed something about arrays i should know because i'm confused on how this ACTUALLY works. I understand the procedure but not the code.

Ples help
Screenshot_230.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Bubble Sort
C#CC# / help
4y ago
Having trouble understanding patterns
C#CC# / help
3y ago
❔ I'm having trouble with my assigment and I need help understanding
C#CC# / help
3y ago
✅ I'm having trouble understanding what is going on within this selection search
C#CC# / help
4y ago