Re: "Sorting" assignment
- From: Julienne Walker <happyfrosty@xxxxxxxxxxx>
- Date: Tue, 5 Feb 2008 08:20:56 -0800 (PST)
On Feb 5, 10:56 am, spinoza1111 <spinoza1...@xxxxxxxxx> wrote:
What's interesting is how excited people have gotten about truly de
minimis performance issues while claiming, in practice, that an N^2
algorithm such as tbe bubble sort should be given a free pass because
it seems, oh, so very simple. Sure, it's simple, so simple that in
implementing it you learn nothing of value.
Learning bubble sort can teach you a lot about algorithms. For
example, you can use bubble sort as a simple implementation for adding
step-based execution and performance analysis. It's a simple algorithm
for introducing asymptotic notation and time complexity. It's also an
immediately useful exercise that covers non-trivial loop and array
logic, modularization, and comparison based sorting. I'd hardly call
that "nothing of value".
Keep in mind that those learning bubble sort are likely to be very new
to programming, so while implementing the algorithm won't teach *you*
anything, it's very instructive to a less experienced programmer.
Naturally this is rather dependent on the teacher understanding these
lessons and guiding his or her students into learning them.
In modern, which is to say object oriented systems, sorts can be
provided once and for all for any array of any type by using generic
parameters. Which would seem to imply that sort should be taught
starting with quick sort, because in implementing it you do a
recursive call.
I'm not sure I understand how you used "object oriented systems" and
"using generic parameters" to reach the conclusion of quicksort should
be taught because it uses a recursive call. I also disagree that
quicksort should be the first sort taught to a student. You'd have to
wait until after recursion was introduced (quicksort is too
complicated to be an introduction to recursion), and even then it's an
extremely subtle algorithm that's better suited to students who have
had experience with simpler sorting algorithms.
In an ideal situation I (as the teacher) would give each student a
list of numbers and ask them to put it in order. That would give me an
idea of what sorting algorithm they think in and introduce them to the
simplest algorithm that implements that technique.
For example, I think in selections, so I would find selection sort to
be the easiest to learn as my first sort. I remember bubble sort
confused the hell out of me because I think in selection and not
exchange. I had similar difficulties with insertion sort, shell sort,
and quicksort, but I picked up heap sort without any effort at all. So
in my experience, the best sort to teach first is the one that the
student is most likely to identify with.
I'd wager that the two algorithms born of that trick would be
selection sort and insertion sort, both of which are very simple and a
good stepping stone for moving into more efficient techniques.
-Jul
.
- Follow-Ups:
- Re: "Sorting" assignment
- From: spinoza1111
- Re: "Sorting" assignment
- References:
- "Sorting" assignment
- From: Ivica
- Re: "Sorting" assignment
- From: spinoza1111
- Re: "Sorting" assignment
- From: Bartc
- Re: "Sorting" assignment
- From: spinoza1111
- Re: "Sorting" assignment
- From: Bartc
- Re: "Sorting" assignment
- From: Malcolm McLean
- Re: "Sorting" assignment
- From: spinoza1111
- "Sorting" assignment
- Prev by Date: Re: Biulding Blocks
- Next by Date: Re: Message from spinoza1111
- Previous by thread: Re: "Sorting" assignment
- Next by thread: Re: "Sorting" assignment
- Index(es):
Relevant Pages
|