 Hey everybody. So this quick video, we're just gonna wrap up on sorting algorithms and summarize and what I expect you to know about these things, right? So we talked about five different sorting algorithms, bubble sort, selection sort, insertion sort, quicksort, and merge sort. The first three are big O of n squared algorithms in the last two are n log n. So I expect you to know basically how they work. How do these things approach the problem of sorting a list? I don't expect you to be able to regurgitate the precise pseudocode for the algorithms but you should know more or less how they work and definitely you should be able to trace the execution of these algorithms if I do give you the pseudocode for them, right? So as a reminder how well these algorithms performed, I know we're talking about big O and big O always talks about worst-case time complexity. What we're talking about here are the cases as they deal with the arrangement of the data. So just like in our search algorithms, right? We could do linear search for unsorted data or if we knew there was a sort, the data was sorted, we could do smart linear or binary search. Same thing for sorting. The arrangement of the data matters on how well these things perform. Most cases though, most data that you want to sort is randomly distributed. It's randomly ordered and that's what the average case here is talking about. But there are a few worst cases for these algorithms. In particular, the big one is that quicksort is big O of n squared if the data is already ordered in some way. But if the data is already ordered in some way, you probably should know that as the developer. And so why are you trying to sort it to begin with? And then there's a case for insertion sort where if the data is already sorted, it's only big O of n, right? But in general, the average case is what we care about here. What do I expect you to know about sorting? We went over a lot. It's a lot of information. Here's what I want you to be able to do. If I give you the pseudo code for the algorithm or part of the algorithm, you should be able to trace the execution of the sorting algorithms applied to the list. I expect you to be able to do what we did in the handouts. I need you to know, is the sort stable or not, right? It will tell you that kind of gives you as the developer a hint of which sort you may want to use or which sorts you cannot use. You should know the average case may go for each algorithm and you should know what the special cases are, the worst case and best case scenario, where the cause, the sorting algorithm to be the most inefficient, right? What are, you know, when are these things bad? I've kind of summarized this knowledge for you in this table. Not going to go over the table. It's for you to study, right? Why do I want you to know? Well, sorts, you got to know when they're appropriate to use and what their tradeoffs are. To that end, your assignment for sorting is not going to be a coding assignment. It is going to be something that I call the sorting sleuth. So the sorting sleuth, let's see if I won't be able to make it any larger on the screen, I don't think, not in an intuitive way. The sorting sleuth is going to be an experiment. So I have a little program here that will generate random lists for you. Those lists will be lists of numbers, right? And you control the length of the list. And then you can also control, is the stuff in the list, is it random? Is it ordered? Is it almost ordered? Or is it in reverse order? And some of the sorting algorithms don't like reverse order. These buttons here are tied to sorting algorithms. So your job in homework assignment number eight, I believe, is to figure out which sorting algorithm is tied to which button. So the way you do that is you experiment. And each time you run the sort, it tells you how many comparisons were done, how many movements or swaps were done, and the total time it took to do the sort. So you can see here some of these are faster than others. And the effect becomes more pronounced as you get bigger in size. So that should tell you something about the big O of n squared of these things. But also it matters what order they're in, remember? Because some of these algorithms do better if the data is partially sorted and some of them do terrible if the data is in reverse order. So your job is to experiment, to play with these two parameters up here, the order of the list and the size of the list, and use that to figure out what these different sorts are. OK, so one last thing I'll have you do is I'll put the link to this sorting video, sorting with sound. It's a YouTube video. It's pretty neat. And it kind of helps illustrate in maybe a different way how some of these sorts are found. So I'll leave it off there. I'll put a link to this video. Let me know if you have any questions and I'll see you next time.