- Where Developers Learn, Share, & Build Careers
Can someone explain to me what I do wrong?
Example: I have no order array int [] uA = { 2, 9, 4, 13, 11, 7, 8 }; I take "9" as a pivot element and after the first repetition of the escape (quick sequence) I will have this array {2, 8, 4, 7, 11, 13, 9}. Where will the middle indicator be shown on "11" and what does it mean? Not all elements are bigger than 11 to 11. And 11 is not exactly the right place. But, for example, I want to return the 5th smallest element (11). is not right on the axis, you can see the position of the axis right at the end of the partition Pivot should be kept at the place. (You do not really need to pay attention to the medium element) then you can calculate the smallest element to use this information, assuming that at the end of the partition the axis is on xth index;
of = x = & gt; The correct answer to the smoke is K & lt; X = & gt; The answer is in the left partition; search left partition K & gt; X = & gt; The answer is in the right partition, find the correct partition
Comments
Post a Comment