title

Java Quick Sort

description

Get the Code Here: http://goo.gl/zPL7r
Welcome to my Java Quick Sort tutorial! In most situations the Quick Sort is the fastest sorting algorithm.
In essence, the quick sort works by partitioning arrays so that the smaller numbers are on the left and the larger are on the right. I'll cover what partitioning is in this video.
The Quick Sort then recursively sends small parts of larger arrays to itself and partitions again. Between the code and the video you will completely get it in the end.

detail

{'title': 'Java Quick Sort', 'heatmap': [{'end': 444.342, 'start': 439.441, 'weight': 0.78}, {'end': 614.324, 'start': 504.797, 'weight': 0.777}], 'summary': "Explores the java quicksort algorithm, highlighting its speed and explaining the partitioning process and code implementation. it also delves into array sorting, quicksort partitioning, and the algorithm's recursive sorting of smaller sub-arrays for efficient sorting.", 'chapters': [{'end': 120.747, 'segs': [{'end': 97.004, 'src': 'embed', 'start': 0.109, 'weight': 0, 'content': [{'end': 7.211, 'text': 'Well hello Internet and welcome to part eight of my Java algorithms tutorial and this is part three of the sorting part of the algorithms tutorial.', 'start': 0.109, 'duration': 7.102}, {'end': 9.712, 'text': "And today we're going to talk about the quicksort.", 'start': 7.392, 'duration': 2.32}, {'end': 16.114, 'text': 'So what is the quicksort? Well in most situations the quicksort is the fastest sorting algorithm out there.', 'start': 9.992, 'duration': 6.122}, {'end': 37.447, 'text': 'The quicksort works by partitioning arrays so that the smaller number of larger arrays to itself and partitions those smaller parts until the whole entire array is in order or sorted.', 'start': 16.235, 'duration': 21.212}, {'end': 40.13, 'text': "So let's look a little bit closer at what partitioning is.", 'start': 37.647, 'duration': 2.483}, {'end': 72.955, 'text': "Now in partitioning, what you need to do is and that's a big part of the quicksort.", 'start': 41.152, 'duration': 31.803}, {'end': 75.818, 'text': "So let's see how to put partitioning into code.", 'start': 73.095, 'duration': 2.723}, {'end': 83.787, 'text': "Okay, so, like I said, when we partition data, we're dividing it into two parts, and all items with data above a defined value, which is the pivot,", 'start': 76.078, 'duration': 7.709}, {'end': 85.609, 'text': 'will go in one part and the rest will go in the other.', 'start': 83.787, 'duration': 1.822}, {'end': 97.004, 'text': "So what we're going to do here is we're going to define And all the code here is available in a link in the description underneath the video.", 'start': 85.789, 'duration': 11.215}], 'summary': 'Part 8 of java algorithms tutorial explains quicksort, the fastest sorting algorithm. it works by partitioning arrays and is available in the video description.', 'duration': 96.895, 'max_score': 0.109, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA109.jpg'}], 'start': 0.109, 'title': 'Java quicksort algorithm', 'summary': 'Introduces the quicksort algorithm as the fastest sorting algorithm, explaining its process of partitioning arrays and its code implementation.', 'chapters': [{'end': 120.747, 'start': 0.109, 'title': 'Java quicksort algorithm', 'summary': 'Introduces the quicksort algorithm as the fastest sorting algorithm in most situations, explaining its process of partitioning arrays and its code implementation.', 'duration': 120.638, 'highlights': ['The quicksort is considered the fastest sorting algorithm in most situations.', 'The quicksort works by partitioning arrays into smaller and larger parts until the entire array is sorted.', 'In partitioning, items with data above a defined value (the pivot) go in one part, and the rest go in the other.', 'The code implementation for partitioning and setting up the array size is available in the description below the video.']}], 'duration': 120.638, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA109.jpg', 'highlights': ['The quicksort is considered the fastest sorting algorithm in most situations.', 'The quicksort works by partitioning arrays into smaller and larger parts until the entire array is sorted.', 'In partitioning, items with data above a defined value (the pivot) go in one part, and the rest go in the other.', 'The code implementation for partitioning and setting up the array size is available in the description below the video.']}, {'end': 644.941, 'segs': [{'end': 188.354, 'src': 'embed', 'start': 121.068, 'weight': 3, 'content': [{'end': 127.016, 'text': "And then we're just going to call generate random array, which I've shown you in past tutorials how exactly that works.", 'start': 121.068, 'duration': 5.948}, {'end': 132.605, 'text': "And you can actually see it right here, generate random array, but because that doesn't have much to do with partitioning, I'm going to skip that.", 'start': 127.377, 'duration': 5.228}, {'end': 158.903, 'text': "So now let's jump in here for the right pointer, which we're going to create here in a second, to find a value that is less than the pivot.", 'start': 132.805, 'duration': 26.098}, {'end': 160.685, 'text': 'then those items are going to be switched.', 'start': 158.903, 'duration': 1.782}, {'end': 162.367, 'text': "so that's all that's going to happen there.", 'start': 160.685, 'duration': 1.682}, {'end': 169.016, 'text': "so of course we're going to need to also come in here and create right pointer and it's going to get a value of,", 'start': 162.367, 'duration': 6.649}, {'end': 188.354, 'text': 'and then wait for right pointer to finish cycling.', 'start': 186.092, 'duration': 2.262}], 'summary': 'Tutorial on creating right pointer for partitioning algorithm.', 'duration': 67.286, 'max_score': 121.068, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA121068.jpg'}, {'end': 309.315, 'src': 'embed', 'start': 285.354, 'weight': 1, 'content': [{'end': 292.457, 'text': 'and this is going to get changed to right pointer, of course, and we are looking for values in this situation that are greater than pivot.', 'start': 285.354, 'duration': 7.103}, {'end': 295.678, 'text': 'so this is going to cycle through until it finds a number that needs switched,', 'start': 292.457, 'duration': 3.221}, {'end': 301.8, 'text': 'with something over here with which is going to match up in the right pointer, and then they are going to switch each other.', 'start': 295.678, 'duration': 6.122}, {'end': 309.315, 'text': "that's all that's going should do exactly the same thing here.", 'start': 301.8, 'duration': 7.515}], 'summary': 'Algorithm cycles through values greater than pivot, switches with right pointer.', 'duration': 23.961, 'max_score': 285.354, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA285354.jpg'}, {'end': 366.161, 'src': 'embed', 'start': 326.639, 'weight': 2, 'content': [{'end': 331.42, 'text': 'Now what I need to do is handle the fact that way up here I put while true.', 'start': 326.639, 'duration': 4.781}, {'end': 359.357, 'text': "so I'm going to have to find a way out of that right pointer and I'm just gonna say swap values, left pointer and right pointer,", 'start': 331.42, 'duration': 27.937}, {'end': 360.478, 'text': "and they're gonna swap.", 'start': 359.357, 'duration': 1.121}, {'end': 365.28, 'text': "and I also created swap values here at a time which you've seen this in the past parts of the tutorial.", 'start': 360.478, 'duration': 4.802}, {'end': 366.161, 'text': "so there's that.", 'start': 365.28, 'duration': 0.881}], 'summary': 'Handling the while loop by swapping values between left and right pointers.', 'duration': 39.522, 'max_score': 326.639, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA326639.jpg'}, {'end': 444.342, 'src': 'heatmap', 'start': 439.441, 'weight': 0.78, 'content': [{'end': 443.342, 'text': 'the left pointer finds 59 and says, hey, this is greater than 35.', 'start': 439.441, 'duration': 3.901}, {'end': 444.342, 'text': 'We need to get rid of it.', 'start': 443.342, 'duration': 1}], 'summary': 'Left pointer finds 59, greater than 35.', 'duration': 4.901, 'max_score': 439.441, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA439441.jpg'}, {'end': 503.496, 'src': 'embed', 'start': 465.406, 'weight': 0, 'content': [{'end': 489.502, 'text': 'And in this situation, there is nothing else less and over and over again,', 'start': 465.406, 'duration': 24.096}, {'end': 496.79, 'text': 'until everything that is less than 35 is on this side of the screen and everything that is greater than 35 is on that side of the screen.', 'start': 489.502, 'duration': 7.288}, {'end': 498.551, 'text': 'And that is partitioning.', 'start': 496.93, 'duration': 1.621}, {'end': 503.496, 'text': "So now let's take a look at how the quicksort uses partitioning to sort faster than anything else.", 'start': 498.751, 'duration': 4.745}], 'summary': 'Quicksort uses partitioning to sort faster than anything else.', 'duration': 38.09, 'max_score': 465.406, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA465406.jpg'}, {'end': 614.324, 'src': 'heatmap', 'start': 504.797, 'weight': 0.777, 'content': [{'end': 512.205, 'text': "Okay, so what you see here is there's a pivot value of 21 defined and we are in essence doing exactly the same things.", 'start': 504.797, 'duration': 7.408}, {'end': 518.302, 'text': 'Here that is less than or equal to 21.', 'start': 512.485, 'duration': 5.817}, {'end': 521.663, 'text': 'In that situation, we have to move it over to the right hand side of the screen.', 'start': 518.302, 'duration': 3.361}, {'end': 523.464, 'text': 'Again, left pointer, right pointer.', 'start': 521.863, 'duration': 1.601}, {'end': 526.926, 'text': 'This is the quicksort, just so I make 100% sure you understand that.', 'start': 523.524, 'duration': 3.402}, {'end': 532.969, 'text': 'So our goal here on the right is to find a value that is greater than 21.', 'start': 527.146, 'duration': 5.823}, {'end': 535.89, 'text': "And here, we're looking for a value that is less than 21.", 'start': 532.969, 'duration': 2.921}, {'end': 536.89, 'text': "And then we're going to switch them.", 'start': 535.89, 'duration': 1}, {'end': 539.812, 'text': 'You can see right here, 16 is definitely less than 21.', 'start': 537.05, 'duration': 2.762}, {'end': 541.112, 'text': 'So we have to switch it.', 'start': 539.812, 'duration': 1.3}, {'end': 542.753, 'text': 'And right here is 21.', 'start': 541.373, 'duration': 1.38}, {'end': 544.514, 'text': 'And these guys are going to switch on the next panel.', 'start': 542.753, 'duration': 1.761}, {'end': 549.684, 'text': 'through here.', 'start': 549.244, 'duration': 0.44}, {'end': 552.127, 'text': '38 needs switched with 19.', 'start': 549.704, 'duration': 2.423}, {'end': 555.089, 'text': "And we skipped 55 because it's greater than our pivot.", 'start': 552.127, 'duration': 2.962}, {'end': 557.992, 'text': 'And now you can see 19 and 38 have been switched as well.', 'start': 555.289, 'duration': 2.703}, {'end': 561.114, 'text': 'Then again, 52 needs to be moved.', 'start': 558.252, 'duration': 2.862}, {'end': 563.977, 'text': '53 and 30 are both greater than a pivot.', 'start': 561.134, 'duration': 2.843}, {'end': 566.379, 'text': "So we've reached this dead end here.", 'start': 564.217, 'duration': 2.162}, {'end': 570.002, 'text': 'And now you can see that 19 and 52 have both switched.', 'start': 566.679, 'duration': 3.323}, {'end': 572.124, 'text': "However, there's nothing more to partition.", 'start': 570.262, 'duration': 1.862}, {'end': 580.75, 'text': 'left pointer was at that point in time is saved as the new pivot,', 'start': 576.749, 'duration': 4.001}, {'end': 587.293, 'text': "and then we start cycling through to see if we can find a situation in which we're going to be able to switch from the left to the right.", 'start': 580.75, 'duration': 6.543}, {'end': 588.533, 'text': 'In this situation.', 'start': 587.473, 'duration': 1.06}, {'end': 589.734, 'text': 'no, we are not,', 'start': 588.533, 'duration': 1.201}, {'end': 598.057, 'text': 'because 19 is too small and you can see that the left pointer and the right pointer almost immediately come together again not able to do any switching.', 'start': 589.734, 'duration': 8.323}, {'end': 605.896, 'text': "and that's now 52.", 'start': 604.955, 'duration': 0.941}, {'end': 614.324, 'text': "Then you can see again we're moving the left pointer down and the right pointer and we're doing switching and we're changing the pivot whenever these two guys are going to meet,", 'start': 605.896, 'duration': 8.428}], 'summary': 'Quicksort algorithm with pivot value 21, switching values to left and right, resulting in final sorted array.', 'duration': 109.527, 'max_score': 504.797, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA504797.jpg'}], 'start': 121.068, 'title': 'Array sorting and quicksort partitioning', 'summary': 'Explains the process of partitioning in array sorting and quicksort, demonstrating the creation of left and right pointers, and separating elements greater and less than a pivot value for faster sorting. detailed examples and descriptions are provided.', 'chapters': [{'end': 403.381, 'start': 121.068, 'title': 'Partitioning in array sorting', 'summary': 'Explains the process of partitioning in array sorting, with a focus on creating left and right pointers to find and switch values less than and greater than the pivot, ultimately leading to a sorted array.', 'duration': 282.313, 'highlights': ['The chapter explains the process of creating left and right pointers to find and switch values less than and greater than the pivot, ultimately leading to a sorted array.', 'The tutorial shows the use of while loop and swap values to handle the partitioning process effectively.', 'The concept of generating a random array is mentioned as a prerequisite for the partitioning process.']}, {'end': 644.941, 'start': 403.601, 'title': 'Understanding quicksort partitioning', 'summary': 'Explains the process of partitioning in quicksort, demonstrating how it separates elements greater and less than a pivot value, leading to faster sorting, with detailed examples and descriptions.', 'duration': 241.34, 'highlights': ['The process of partitioning in quicksort separates elements greater and less than a pivot value, leading to faster sorting.', 'The left and right pointers cycle through the array to find values greater and less than the pivot, switching them accordingly.', 'The algorithm dynamically adjusts the pivot and the pointers to efficiently partition the elements, ultimately achieving a sorted array.']}], 'duration': 523.873, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA121068.jpg', 'highlights': ['The process of partitioning in quicksort separates elements greater and less than a pivot value, leading to faster sorting.', 'The left and right pointers cycle through the array to find values greater and less than the pivot, switching them accordingly.', 'The tutorial shows the use of while loop and swap values to handle the partitioning process effectively.', 'The chapter explains the process of creating left and right pointers to find and switch values less than and greater than the pivot, ultimately leading to a sorted array.', 'The algorithm dynamically adjusts the pivot and the pointers to efficiently partition the elements, ultimately achieving a sorted array.', 'The concept of generating a random array is mentioned as a prerequisite for the partitioning process.']}, {'end': 1107.805, 'segs': [{'end': 684.786, 'src': 'embed', 'start': 644.941, 'weight': 0, 'content': [{'end': 650.504, 'text': "so now that you've seen a rough overview of how the quicksort works, let's go and look at the quicksort in code.", 'start': 644.941, 'duration': 5.563}, {'end': 656.708, 'text': "okay, so we're going to need an array and we're going to need array size, just like we had previously.", 'start': 650.504, 'duration': 6.204}, {'end': 684.786, 'text': "so let's just go and throw that in there video, if you want it, and then we're gonna get down into the actual quicksort.", 'start': 656.708, 'duration': 28.078}], 'summary': 'Overview of quicksort algorithm and implementation in code.', 'duration': 39.845, 'max_score': 644.941, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA644941.jpg'}, {'end': 850.918, 'src': 'embed', 'start': 819.248, 'weight': 1, 'content': [{'end': 823.452, 'text': 'The part that needs to be finished now is the partitioning part, which you already saw.', 'start': 819.248, 'duration': 4.204}, {'end': 826.956, 'text': "So, here again, we're just going to go into left pointer,", 'start': 823.673, 'duration': 3.283}, {'end': 844.012, 'text': "because And you're going to see exactly the same thing in regards to how we're going to search.", 'start': 826.956, 'duration': 17.056}, {'end': 850.918, 'text': "So we're going to say the array increment left pointer while it is less than pivot.", 'start': 844.292, 'duration': 6.626}], 'summary': 'The partitioning part of the array needs to be finished, incrementing the left pointer until it is less than the pivot.', 'duration': 31.67, 'max_score': 819.248, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA819248.jpg'}], 'start': 644.941, 'title': 'Quicksort algorithm', 'summary': 'Provides an introduction to understanding quicksort in code, discussing the array and array size requirements, and explaining the process of quicksort algorithm, involving partitioning arrays and recursively sorting smaller sub-arrays until the entire array is sorted.', 'chapters': [{'end': 737.098, 'start': 644.941, 'title': 'Understanding quicksort in code', 'summary': 'Provides an introduction to understanding quicksort in code, discussing the array and array size requirements, and mentioning the optional stopping condition for improved speed.', 'duration': 92.157, 'highlights': ['The chapter discusses the array and array size requirements for implementing quicksort, providing a practical approach to understanding the process.', 'The transcript mentions the optional stopping condition for improved speed, indicating that it is sometimes beneficial and sometimes not, thus acknowledging the variable impact on performance.']}, {'end': 1107.805, 'start': 737.098, 'title': 'Understanding quicksort algorithm', 'summary': 'Explains the process of quicksort algorithm, which involves partitioning arrays and recursively sorting smaller sub-arrays until the entire array is sorted, using examples and step-by-step explanation.', 'duration': 370.707, 'highlights': ["The quicksort algorithm involves recursively sorting smaller arrays until the entire array is sorted. The quicksort algorithm's main job is to make arrays smaller and smaller to be partitioned, and the partition part does exactly what the previous code did.", 'The partitioning process involves searching through the array to find values that need to be switched, using left and right pointers. The partitioning process includes searching through the array with left and right pointers to find values that need to be switched, and then recursively partitioning and sorting the sub-arrays until the entire array is sorted.', 'The process continues until the entire array is sorted, with smaller sub-arrays being recursively partitioned and sorted. The process of partitioning and sorting continues recursively until the entire array is sorted, with smaller sub-arrays being processed each time until the sorting is complete.']}], 'duration': 462.864, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/mN5ib1XasSA/pics/mN5ib1XasSA644941.jpg', 'highlights': ['The chapter discusses the array and array size requirements for implementing quicksort, providing a practical approach to understanding the process.', 'The process of partitioning and sorting continues recursively until the entire array is sorted, with smaller sub-arrays being processed each time until the sorting is complete.', 'The partitioning process involves searching through the array to find values that need to be switched, using left and right pointers.']}], 'highlights': ['The quicksort is considered the fastest sorting algorithm in most situations.', 'The process of partitioning in quicksort separates elements greater and less than a pivot value, leading to faster sorting.', 'The chapter discusses the array and array size requirements for implementing quicksort, providing a practical approach to understanding the process.', 'The quicksort works by partitioning arrays into smaller and larger parts until the entire array is sorted.', 'The process of partitioning and sorting continues recursively until the entire array is sorted, with smaller sub-arrays being processed each time until the sorting is complete.', 'In partitioning, items with data above a defined value (the pivot) go in one part, and the rest go in the other.', 'The left and right pointers cycle through the array to find values greater and less than the pivot, switching them accordingly.', 'The tutorial shows the use of while loop and swap values to handle the partitioning process effectively.', 'The chapter explains the process of creating left and right pointers to find and switch values less than and greater than the pivot, ultimately leading to a sorted array.', 'The algorithm dynamically adjusts the pivot and the pointers to efficiently partition the elements, ultimately achieving a sorted array.', 'The concept of generating a random array is mentioned as a prerequisite for the partitioning process.', 'The code implementation for partitioning and setting up the array size is available in the description below the video.']}