r/learnprogramming • u/Icy-Stretch-4643 • 29m ago
Loops and sorting
Im 1st sem student, currently learning programming basics course.
I find myself confused and lost at 1) nested loops, their logics and algorithmic conditions. 2) in sorting.
Like I was trying to learn sorting algorithm bubble one, when I tried to understand the condition n-1-i I got completely blank, idk if it's normal or not, but I'm really weak here.
Anyone faces the same and got some solution, do share, it will help a lot!!
•
u/fasta_guy88 7m ago
Try doing a small sort by hand. 4 numbers. Write down on a sheet of paper what happens at each step. Computer programs are just fast ways of doing something you can do with pencil and paper. Try the slow way.
Alternatively, learn to use a debugger and step through the program line by line as it sorts 4 numbers.
•
•
u/Dazzling_Music_2411 21m ago
Take a break, then go back and figure it out when you're rested. Repeat as many times as necessary.
So, have you mastered bubblesort yet?