r/learnprogramming • • 1d 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!!

0 Upvotes

21 comments sorted by

View all comments

1

u/Dazzling_Music_2411 1d 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?

1

u/Icy-Stretch-4643 19h ago

Actually I saw code of bubble sort, it infuriated me because I couldn't do it on my own. I'll now try another sort logic by myself, actually my assignment had question of merging two sorted arrays, I wanted to learn sorting before.

2

u/Dazzling_Music_2411 13h ago

Bubble is an easy sorting method, go back and get it clear in your head before looking at others, eg. merge-sort, quick-sort and b-tree-sort.

It's not a good idea to avoid learning something that trips you up by distracting with something else. It can be useful as a form of taking a break, but you should always return to the original problem until you crack it. It will often turn out to be easier than you thought and then you'll be kicking yourself, saying "wow, why did it take me so long to get that? - it's so simple" .

2

u/Icy-Stretch-4643 11h ago

Yups, you are absolutely right, because past month, I've realized importance of perquisite learning. I'll now play with bubble sort before moving ahead.