ORDER BY PART-2
This part of the blog is in continuation with ORDER BY PART-1 where we discussed the algorithm of quick sort. Now here we will see the code where it is applied to the program.
Here if file is not in array then we call it to array first.
Then we have two choices whether to sort by pages or by count. This choice will be passed as an argument to sorting(), where we will have a switch case.
Here if file is not in array then we call it to array first.
Then we have two choices whether to sort by pages or by count. This choice will be passed as an argument to sorting(), where we will have a switch case.
Arguments low and top are the end points of array for quick sort. If it is a valid array i.e. low<high then go to function parti() which returns the updated pivot element.
sorting(low,pi-1,choice); is for left side of pivot.
sorting(pi+1,high,choice); is for right part of pivot.
Here according to choice we perform the algorithm on either pages or count attribute. Inside switch we select pivot element which is always the last element of array.
In the above part of code, again according to the choice the algorithm proceeds. Swapping of array elements take place as per the algorithm and finally the parti() function returns the value of new pivot element.
Great work keep posting!!!
ReplyDeleteThank you
DeleteGreat Work Ladsππ
ReplyDeleteThank you
DeleteInformative
ReplyDeleteGreat
ReplyDeleteGood explanation!!
ReplyDeleteThank you
DeleteGood work π
ReplyDeleteHelpful!
ReplyDeleteMade the idea very clear
ReplyDeleteGreat work
ReplyDeleteNice
ReplyDeleteCompletely loved the content
ReplyDeleteThank you
Deleteπππ
ReplyDelete