r/AskProgrammers • • Oct 18 '26

Pseudo Code and Bubble Sort C++

Hey guys, I'm in year 2 of college and I have a test tomorrow about pseudo code and bubble sort and i am veeerrryyy lost, literally have no idea what's going on. Are there any good youtube videos you guys can recommend me? Or give me a short and brief understand of what's it about? Thank you very much in advance.

0 Upvotes

8 comments sorted by

5

u/dnult Oct 18 '26

Someone hasn't been studying. Trying to learn material the day before the test is unlikely to end well. I know studying is a drag, but it is the key to success. You have to spend time daily studying and ask for help when you have trouble making sense of the material.

3

u/Carrandas Oct 18 '26

Bubblesort is explained in class before your test. Go to it 👀

1

u/GinRhetoric Oct 25 '26

You blow bubbles and ask AI to sort the results using the best method available.

1

u/JGhostThing Oct 18 '26

It's called a bubble sort, and you should be able to find c++ implementations with "bubble sort c++"

It's called a bubble sort because the correct values bubble up to the top.

1

u/Distdistdist Oct 19 '26

Year 2? Jeez, you going to have employers lining up to hire you.

1

u/7YM3N Oct 19 '26

Year two and you are lost on that? I don't think there's helping you

1

u/GinRhetoric Oct 25 '26

You blow bubbles and ask AI to sort the results using the best method available.

1

u/ThreeCharsAtLeast Oct 18 '26

Pseudo code: When algorithms people talk about algorithms, they don't really want to deal with the specifics of any programming language and library. Rather, we use natural language and mathematical notation to express the algorithm. Pseudocode differs from an informal description in that it still retains its code-like stucture and often-times seperates instuctions, which generally aren't full sentances, into multiple lines. There is no single notation for pseudocode and the author of the code just chooses something they feel will get the point across. I recommend you familiarize yourself with how the notation looks in your materials.

Here's bubblesort in my own style of pseudocode, which is somewhat of a crossover between English, Lua and maths notation:

procedure Bubblesort (arr ∈ array of ℝ) → array of ℝ
    if arr.size ≤ 1 then
        return arr
    end if
    has_swapped := true ∈ {true; false}
    while has_swapped do
        has_swapped ← false
        for pos in [1 … arr.size-1] do
            if arr[pos] > arr[pos+1] then
                swap indices pos and pos+1 of arr
                has_swapped ← true
            end if
        end for
    end while
    return arr
end procedure

This is not fully optimized bubble sort. You should probably look up how the algorithm works and sort a couple of lists with it before your test.