Great videos... I've been practicing the implementation of algorithms with Java 6/7 and here's my implementation based on your explanation, Wikipedia, etc...
h t t p : // code.google.com/p/programming-artifacts/source/browse/trunk/workspaces/hacking/data-structures-impl/src/com/google/code/datastrut/sort/algorithm/SelectionSortStrategy.java
Hello, thanks for your comment. Your suggestion works too, and is in fact a more elegant approach to selection sort. However, i chose the method as demonstrated since it's much more intuitive, and becomes easier to understand.
There is no strict rule defining how to implement a sorting algorithm, as long as the concept, in this case the idea of selection, is there.
I did a bit of reading up, and turns out you're right. The in-place property was actually part of Selection sort's definition, I actually thought it was merely an implementation choice. I'll probably make a video this weekend as an addon to this video.
Thanks! I'm not very good with many sorting algorithms (in fact, most of these are self-studied), so I don't really dare to go into those I'm not so sure about!
Another good tutorial. My only question is I never really got the n-2 or n-1 stuff at the end. Is that essentially saying n-2 (so second from the end?) as a way of classifying the distance to the end for the use in the example?
You're thinking in the right direction, though you made a mistake. I'll explain:
By saying "there are n items in the list", we can infer that the last item in the list is also the "nth item" - So if there are 7 items in the list, then the last item would be the 7th item.
So the "n-1"-th item in a list would be the second last item (not n-2, as you incorrectly said). In a list of 7 items, isn't the (n-1 = 7-1)th item, in other words the 6th item, the second last item?
This has been flagged as spam show
That is an "invincible" video. =p
efraimgarner 1 month ago
This has been flagged as spam show
This video went viral on Rangoon
leighstephens74 2 months ago
Great videos... I've been practicing the implementation of algorithms with Java 6/7 and here's my implementation based on your explanation, Wikipedia, etc...
h t t p : // code.google.com/p/programming-artifacts/source/browse/trunk/workspaces/hacking/data-structures-impl/src/com/google/code/datastrut/sort/algorithm/SelectionSortStrategy.java
Chears!
marcellosales 10 months ago
This is wrong. There isn't a second array. The array elements are just being swaped.
pithikoulis 1 year ago
@pithikoulis
Hello, thanks for your comment. Your suggestion works too, and is in fact a more elegant approach to selection sort. However, i chose the method as demonstrated since it's much more intuitive, and becomes easier to understand.
There is no strict rule defining how to implement a sorting algorithm, as long as the concept, in this case the idea of selection, is there.
lcc0612 1 year ago
@lcc0612
Sorry, but thats just wrong. The main advantage ist that selection sort is an "inplace" sort algorithm, that does not need extra space.
mongobot 1 year ago
@mongobot
I did a bit of reading up, and turns out you're right. The in-place property was actually part of Selection sort's definition, I actually thought it was merely an implementation choice. I'll probably make a video this weekend as an addon to this video.
lcc0612 1 year ago
did you know, I'm a velociraptor and I know the fastest sorting algorithm, but I will not show it until I find someone that matches my speed...
the name of my algorithm is velocirapsort, get it :P
Jackpotur 1 year ago
[ lcc0612 ] .. simply, You Are The BEST Of All !
dreamerr17 1 year ago
@dreamerr17
Thank you very much!
lcc0612 1 year ago
Thanks .. I like it
aboaziz1 1 year ago
@aboaziz1
Thanks for your kind comment! I'm glad I could be of help!
lcc0612 1 year ago
wow... this helped a lot THANKSS
dbzkidkev2 1 year ago
@dbzkidkev2
Cheers! Glad I could be of help!
lcc0612 1 year ago
you explain good these sort algorithms, you could make also other videos with radix sort and so on.
PUTSAS 1 year ago
@PUTSAS
Thanks! I'm not very good with many sorting algorithms (in fact, most of these are self-studied), so I don't really dare to go into those I'm not so sure about!
lcc0612 1 year ago
Another good tutorial. My only question is I never really got the n-2 or n-1 stuff at the end. Is that essentially saying n-2 (so second from the end?) as a way of classifying the distance to the end for the use in the example?
frampo4 1 year ago
@frampo4
You're thinking in the right direction, though you made a mistake. I'll explain:
By saying "there are n items in the list", we can infer that the last item in the list is also the "nth item" - So if there are 7 items in the list, then the last item would be the 7th item.
So the "n-1"-th item in a list would be the second last item (not n-2, as you incorrectly said). In a list of 7 items, isn't the (n-1 = 7-1)th item, in other words the 6th item, the second last item?
lcc0612 1 year ago
You basically get the idea, I hope - The nth item is the last, the (n-1)th is the second last, and so on.
lcc0612 1 year ago
@lcc0612 Ah ok thanks :)
frampo4 1 year ago
Thanks for uploadding..it really helped
aabrification 1 year ago
@aabrification
Cheers! I'm glad I could be a help!
lcc0612 1 year ago
quite useful,,thax :)
BeYn11160 1 year ago
@BeYn11160
Glad it was a help!
lcc0612 1 year ago