I can't stand Bubble Sort

Pages: 12
Well I have so much egg on my face you could hit me with a frying pan and call me an omelette. The two povusers links Duoas posted convinced me. I think you need to work on your argument skills Duoas, less rhetoric more examples and start earlier with the citations.
i use bubble sort :/ if i need a [b]good[b] one i have smooth sort tucked neatly away in a static library, but in programming competitions i attend i cant use pre written code, so i use quick sort (because i can remember how to implement that) and bubble sort (because its easy to implement so i dont even need to bother remembering)
i cant use pre written code
Use std::sort.
Insertion and selection sorts are N2 too, but they beats bubblesort. They are increadibly easy to implement as well.
Heapsort is tricky, but with std::make_heap and others it is easy to implement as well.
You do know that I work in education, right?

You've mentioned this in the past but you've never been clear about anything specific, I'm not one to cyber-stalk so please forgive me for not looking you up. I could make the same claim, albeit as a volunteer, since I'm a STEM instructor for the GSA (my wife is a troop leader and my daughter is a scout. I was volunteered for this so it's not as creepy as it may sound).

Printing 2-D arrays to the screen are an introduction to embedded loops, but what does printing crap to the screen actually teach you about anything? For a close as you can to real world application you need an example where the state, in this case the position, of each element in the array is dependent on some attribute of every other element. Have you noticed how in some of the instructions that the posters provide they don't make mention of embedded loops at all? Doesn't that strike you as an evaluation of their ability to recall and apply what they should already have learned? If you'd rather choose to believe that the instructors or the curriculum are all pants-on-head retarded then I can't blame you, I don't have much faith in teachers myself.
Duoas wrote:
You do know that I work in education, right?

Why would anyone here know that? Do you really expect people to memorise each trivial factoid about yourself that you off-handedly mention in forgotten threads? This isn't an isolated incident, either, it's recurring; and each time, it's not that what you're saying is wrong but the way you say it with an air of assumed authority and haughty arrogance. I'm trying to ignore my inner armchair psychologist screaming "narcissist", but...
Use std::sort.
Insertion and selection sorts are N2 too, but they beats bubblesort. They are increadibly easy to implement as well.
Heapsort is tricky, but with std::make_heap and others it is easy to implement as well.

i get more points for writing it myself. thanks though ill look into that
So... the chaff hits the wheat...

MiiNiPaa wrote:
I was under impression that you are trying to understand why bublesort is so widespread in CS courses.

Sorry I was rude to you. I was actually just venting. I do know why bubblesort is so widespread. I just posted without regard to the obvious "let's talk about bubblesort" baiting I gave.

I actually respect you and your knowledge of CS. Alas, my point was that people hang on to bubblesort irrationally, and when pressed, they (we?) always present the same (false) reasons that have been drilled into them.

I used to believe the nonsense too -- even when I was learning bubblesort and thinking to myself, "this is a crock".

Thank you for being patient with this cranky old man.


Lachlan Easton wrote:
Well I have so much egg on my face you could hit me with a frying pan and call me an omelette. The two povusers links Duoas posted convinced me. I think you need to work on your argument skills Duoas, less rhetoric more examples and start earlier with the citations.

Your strength of character continually impresses me.

I did not intend (nor appreciate the need) to prove my point -- I assumed (incorrectly) that many here on the forums would know enough about bubblesort to already be past having to decide whether to agree with me or not. Therefore, my efforts were less at teaching and more at idiotic reactionary "thanks for nothing" annoyance.

Sorry.


Computergeek01 wrote:
but what does printing crap to the screen actually teach you about anything?

A surprising amount, but for the purposes here it is an appropriate vehicle for handling nested loops.

Doesn't that strike you as an evaluation of their ability to recall and apply what they should already have learned?

That is the dream of every instructor. (It is usually dashed pretty thoroughly as well -- instructors often have to hand-hold people through application of prior knowledge.)

First and second-semester professors don't have that luxury, though. They cannot assume students have any idea how to handle nested looping or what purposes it may serve. That is why they construct simple exercises that make their students think about and work out/struggle through the algorithm, such as printing stars and triangles to the console window. Their dream is that the exercise will stick with them enough that later courses may do just as you think: apply prior knowledge to the current learning objective.

It is not the instructors (or the curriculae) that are pants-on-retarded. They do it this way because most of their students cannot absorb the information any faster. This is natural. (And those that can are very rarely able to only because they are super smart; they can because they have already been introduced to the concept in some way before.)


chrisname wrote:
Why would anyone here know that? Do you really expect people to memorise each trivial factoid about yourself that you off-handedly mention in forgotten threads?

As we have been posting here together for some years, yes, I do expect people such as yourself to remember some basic facts about me. (Though not, as you pejoratively assert, every 'trivial factoid'.) Just as I know something about you from your posts. This is basic social protocol, and you will find that people in any important strata will expect it.

Frankly, the recurring issue is that you are aggressively rude to me.

it's not that what you're saying is wrong but the way you say it with an air of assumed authority and haughty arrogance

It's not arrogance or assumed authority -- it's plain old annoyance.

It is annoying when people make statements that present themselves as knowledgeable about something -- because they believe their own intelligence has given them a greater understanding of the subject than actual, good-ol' education -- when those statements peg them as waay over their heads.

And then have the gall to be unrepentant about it.

I've done my share of being stupid, so I understand -- really, I do. And there's plenty of stuff I don't know squat about. But guess what? I don't go and start spouting off in threads about it like I know something. I keep my (figurative) trap shut, and let the thread be handled by those who (presumably) know what they are talking about.

So you might want to consider the mote in your own eye before you start taking me to task for my perceived narcissism.


SORTS

The STL actually has a number of useful sorts or sorting subfunctions built-in, including (but not limited to) introsort (which takes the place of quicksort), mergesort, heapsort, and insertion sort.

(std::sort() is introsort, or in old STL implementations, quicksort, and std::stable_sort() is usually mergesort.)
Duoas wrote:
As we have been posting here together for some years, yes, I do expect people such as yourself to remember some basic facts about me

Of course we'd remember some things about each other, but to be irked that someone could forget such a specific detail seemed ludicrous. Especially since a specific poster may not have looked at the specific thread(s) where you mentioned that specific fact.

you will find that people in any important strata will expect it

This forum is an important stratum?

Frankly, the recurring issue is that you are aggressively rude to me.

I hope you don't think it's just you. I'm generally disagreeable, it isn't personal.

It's not arrogance or assumed authority -- it's plain old annoyance.

That's not how it sounds. And even if it is annoyance, the internet, where the time between responses is hours rather than milliseconds, isn't exactly the most emotionally charged medium; remaining emotionally detached is easy.

So you might want to consider the mote in your own eye before you start taking me to task for my perceived narcissism.

Tu quoque. My hypocrisy in taking a position doesn't affect the truth of that position. It doesn't matter if the pot calling the kettle black is also black; the kettle is still black.
Nah, you're just a jerk. You can't stand it when someone disagrees with you.

https://xkcd.com/386/

So why don't you take your own advice and just buzz off?
closed account (z05DSL3A)
"A relationship, I think, is like a shark. You know? It has to constantly move forward or it dies. And I think what we got on our hands is a dead shark." -- Woody Allen
Duoas wrote:
You can't stand it when someone disagrees with you

I actually laughed when I read this. The entire thread is about you not being able to understand people disagreeing with you, and your haughty attitude reflects that. Can you say "projecting"?

Furthermore I haven't said anything about the topic of the thread because I don't care about it, so I don't know what disagreement you're referring to. If you're going to accuse me of being outraged at someone disagreeing with me, make sure someone has actually disagreed with me first.

So why don't you take your own advice and just buzz off?

Nor did I advise anyone, including yourself, to leave, so I don't know where you got that from.

This was a very shoddy attempt at insulting me because it doesn't make any sense in the context. I think you should stop making things up, especially when the entire thread is right there for everyone to see. Or is your ageing brain just too tired to keep up with reality?
Last edited on
I'm going to support Duoas here. Buuble sort is unintuitive. When I was first learning to program and had no instruction on how to do, well anything, the first sorting algorithm I wrote was nearly identical to selection sort.
Last edited on
Interesting, bubble sort was what I first sorting algorithm I wrote with no instruction.
There is one thing I always wondered about your user, Duoas.
Seen as you were given access to write this site's FAQ, were you also given administrator/moderator privileges?

Back on topic, I personally find Bubble Sort to be pretty intuitive.
I do, however, believe that a better "default" sort algorithm would be Selection Sort.
And posted below is one of my favorite C++ code snippets, from CppReference.com:

1
2
3
4
5
6
template<class ForwardIt>
void selection_sort(ForwardIt begin, ForwardIt end)
{
    for (ForwardIt i = begin; i != end; ++i)
        std::iter_swap(i, std::min_element(i, end));
}

Topic archived. No new replies allowed.
Pages: 12