JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label Quick Sort. Show all posts
Showing posts with label Quick Sort. Show all posts

what is Quick Sort?

11:16 PM
Quick Sort Quick sort is the widely used sorting algorithm that makes n log n comparisons in average case for sorting of an array of n elements. This algorithm follows divide and conquer approach. The algorithm processes the array in the following way. Set the first index of the array to left and loc variable. Set the last index of the array to right variable. i.e. left = 0, loc = 0, en d = n ? 1, where n is the length of the array. Start from the right of the array and scan the complete array from right to beginning comparing each element of the array with the element pointed by loc. Ensure that, a[loc] is less than a[right]. If this is the case, then continue with the comparison until right becomes equal to the loc. If a[loc] > a[right], then swap the two values. And go to step 3. Set, loc = right start from element pointed by left and compare each element in its way with the element pointed by the variable loc. Ensure that a[loc] > a[left] if this is the case

.