well, with the heap sort, if your list is already sorted, the algorithm do not detect it and mix up the list to build the heap. In my opinion, it's very bad.
We can improve quicksort speed by using the insertion sort algorithm to sort less than 7 items, rather than continuing by choosing a pivot and etc.
Secondly, in ur QuickSort, choosing a good middle value pivot by random to reduce the number of swaps&compares has some luckyness to it.Recursively do the following.
L&L: Thanks for the informative comments. Yes, I realize there is more to sorting than I covered in that song! In my class, I do touch on some of the other sorts, although I don't go into depth about effective ways to choose pivots (it's not that kind of class). As for shell sort, I always thought it was n x sqrt(n), but wikipedia says it can be made n log^2 n. I don't know how that analysis goes, though.
When you program the QuickSort a common method is simple choose the right most index as the pivot. However, if the set is in ascending or decending order and the sort does the vice sort of this, then this can degrade the QuickSort to O(N^2). Precautions such as knowing the set will be random or using the median of 3 will prevent this.
If one suggestedto writing/using a random generator to choose each pivot,this would certainly slow the Quicksort, due to all the computation overheads in this.
(As a wild say, use slow sorts( O(N)^2 )ones on fewer than 1000 items, Advanced Sorts on anything greater.) Though Moores Law and computation speed is everly increasing and slow sorts are getting seemingly less slow.
If the data isn't random, such as Quicksort Ascending a roughly Decending Set, then a HeapSort is better, or Radix, or MergeSort could possible but the 2 later use more memory also all can be conceptually harder to understand but each are O(N*logN), but these sorts O(N*logN) are minutly slower, then an a QuickSort at (N*logN) best.
Minute diffrence meaning more comparisons, also, if MergeSort is implemented using Recursion also create minor speed diffrences. But as I said better than QuickSort during its Worst Case Scenario.
mlittman for introclasses it will be good to teach basic sorts such as, bubble sort, selection sort then insertion sort. If you fancy squeezing an advance sort, try the Shell sort, as its an clever expansion of Insertion Sort with nice visualisation of its working. Also, its Order(n*logn)^2 slower than QSort.
No, quicksort is bad! Its worst case is quadratic O(n²). Introsort and Mergesort are better than both. All my professors discourage quicksort greatly.
I hadn't heard of introsort, but the wikipedia entry seems misleading. Quicksort with a random pivot is expected n log n and the chance of being Omega(n^2) is exponentially small (facts not even mentioned on the page). Quicksort is fast and lightweight and an astonishing improvement over selection sort. One can engineer it to squeeze as much performance out of it as possible, but that's not really a topic for an intro class.
.. but for me it´s n*log(n) !
LookiLukas 2 months ago 2
This song became the anthem of our CS department lol
wfhbright 7 months ago
You forgot about mergesort?
opliik 9 months ago
I loved it!
twistor96 1 year ago
I am just putting it on my ipod, can I?
MrDoctorTomas 1 year ago
Im so using this for teaching the new students next semester ^^
lximilo 1 year ago
great! let me know how it works out. (if you practice, you can even sort cards that way.)
mlittman 1 year ago
@mlittman
Actually , our assistant professor showed us this video :D
And it worked out fine , for me!
JimbitoCono 1 year ago
I like this song!
d2513850 1 year ago
this is an intersting way 2 explain
gamernabil 2 years ago
Comment removed
OoxXVinceXxoO 2 years ago
thanks! (who was the prof? UIUC is a great school!)
mlittman 2 years ago
Comment removed
OoxXVinceXxoO 2 years ago
awesome
giorgos11235 2 years ago
this is awesome!!
fotis156 2 years ago
Awesome Video!
barrikid 2 years ago
epic!
Faceless989 2 years ago
and i thought i was a nerd 0.o
AtomicNerd001 2 years ago
Don't worry, you are.
ray0kun 2 years ago 2
wow -_-
smart guy 'eh?
AtomicNerd001 2 years ago
cringe
nukz0r 2 years ago
O_o
Da1nOnlyBKB 2 years ago
wow! i loved that music... awesome!
szeb06 2 years ago
That's pretty awesome, gg vid lol.
benutzer2 2 years ago
yyuyu
lolbensuckslol 2 years ago
This has been flagged as spam show
Cool video. We like.
theteacheronline 2 years ago
xDDDDDDDDD thanks a lot xD
MonoCabron123 2 years ago
Es como el plaza sesamo de la progrmacion
jazter1 3 years ago
Gracias!
mlittman 3 years ago
GENIAL!!!
gusgle 3 years ago
oui :) je suis d'accord
HackPirate 3 years ago
Isn't n times through a list linear rather than quadratic?
sg100000000 3 years ago
searching through a list of length n is linear (n). Repeating that operations n times is quadratic (n times n = n squared).
mlittman 3 years ago
SOLID! I WANT MORE!
ambir 3 years ago
great!!!! just great! wish if they could teach us like that at college
shoaibi 3 years ago
a dell made in texas lol i love it. learning this night before midterm. way better than reading books
bashir444 3 years ago
god thats cheesy, informative, but cheesy...
JohnsJava 3 years ago
this is awesome! I like the original version but this is ace.
shizzle5150 3 years ago
thats hilarious
aphididae 3 years ago
man that was funny :)
80amnesia 4 years ago
dude... that was fun ... :)
but yeah i'd rather use heapsort... which i can count on... no worst case scenario...!
andrewsmithty 4 years ago
well, with the heap sort, if your list is already sorted, the algorithm do not detect it and mix up the list to build the heap. In my opinion, it's very bad.
We can improve quicksort speed by using the insertion sort algorithm to sort less than 7 items, rather than continuing by choosing a pivot and etc.
newcoleco 4 years ago
Awesome ! :P i learnt quick sort instantly lolz
arcfenix 4 years ago
So awesome.
CheeZe477 4 years ago
Firstly,excellent fun breakdown of the 2 sorts.
Lem0nAndLime 4 years ago
Secondly, in ur QuickSort, choosing a good middle value pivot by random to reduce the number of swaps&compares has some luckyness to it.Recursively do the following.
Lem0nAndLime 4 years ago
There's a technique called median of 3 that's sorts asc/dsc the middle,start and end index values to obtain a better middle value
Lem0nAndLime 4 years ago
L&L: Thanks for the informative comments. Yes, I realize there is more to sorting than I covered in that song! In my class, I do touch on some of the other sorts, although I don't go into depth about effective ways to choose pivots (it's not that kind of class). As for shell sort, I always thought it was n x sqrt(n), but wikipedia says it can be made n log^2 n. I don't know how that analysis goes, though.
mlittman 4 years ago
When you program the QuickSort a common method is simple choose the right most index as the pivot. However, if the set is in ascending or decending order and the sort does the vice sort of this, then this can degrade the QuickSort to O(N^2). Precautions such as knowing the set will be random or using the median of 3 will prevent this.
Lem0nAndLime 4 years ago
If one suggestedto writing/using a random generator to choose each pivot,this would certainly slow the Quicksort, due to all the computation overheads in this.
(As a wild say, use slow sorts( O(N)^2 )ones on fewer than 1000 items, Advanced Sorts on anything greater.) Though Moores Law and computation speed is everly increasing and slow sorts are getting seemingly less slow.
Lem0nAndLime 4 years ago
If the data isn't random, such as Quicksort Ascending a roughly Decending Set, then a HeapSort is better, or Radix, or MergeSort could possible but the 2 later use more memory also all can be conceptually harder to understand but each are O(N*logN), but these sorts O(N*logN) are minutly slower, then an a QuickSort at (N*logN) best.
Lem0nAndLime 4 years ago
Minute diffrence meaning more comparisons, also, if MergeSort is implemented using Recursion also create minor speed diffrences. But as I said better than QuickSort during its Worst Case Scenario.
Lem0nAndLime 4 years ago
mlittman for introclasses it will be good to teach basic sorts such as, bubble sort, selection sort then insertion sort. If you fancy squeezing an advance sort, try the Shell sort, as its an clever expansion of Insertion Sort with nice visualisation of its working. Also, its Order(n*logn)^2 slower than QSort.
Lem0nAndLime 4 years ago
OmfG THys Is SO0O0OOOoO gHEY.
x0utsideofthis 4 years ago
ehauheiheauhaea, =), very good...
lua121 4 years ago
No, quicksort is bad! Its worst case is quadratic O(n²). Introsort and Mergesort are better than both. All my professors discourage quicksort greatly.
KlokJammer 4 years ago
I hadn't heard of introsort, but the wikipedia entry seems misleading. Quicksort with a random pivot is expected n log n and the chance of being Omega(n^2) is exponentially small (facts not even mentioned on the page). Quicksort is fast and lightweight and an astonishing improvement over selection sort. One can engineer it to squeeze as much performance out of it as possible, but that's not really a topic for an intro class.
mlittman 4 years ago
indeed it is lol. poor selection
galanodell88 4 years ago
holy mother of jesus, thats hilarious!
MeRc3n4rY 4 years ago