Mi vypros na vkus, shtoto if-a pravi edna stypka, dokato while-a pravi
nqkolko stypki, ta na men mi e malko po-lesno da si go predstavq, ama vse
taq.


On 20 March 2014 03:14, andreypetrov <notifications@github.com> wrote:

> In src/Solution.java:
>
> > +
> > +        int low = 0;
> > +        int high = input.length - 1;
> > +
> > +        quicksort(input, low, high);
> > +    }
> > +
> > +    public static void quicksort(int[] input, int low, int high) {
> > +        int medium = low + (high - low)/2;
> > +        int pivot = input[medium];
> > +
> > +        int i = low;
> > +        int j = high;
> > +
> > +        while (i<=j) {
> > +            while(input[i] < pivot) i++;
>
> Ne, tva umira, no leko modificirano mai stava:
>
> if (input[i] < pivot) i++;
> if (input[j] > pivot) j--;
> if (i<=j) {
> swap(input, i, j);
> i++;
> j--;
> }
>
> tva e shtoto zaradi rekursiqta trqbva strogo da im se smenqt mestata na i
> and j. A zashto if e po-dobre ot while?
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/andreypetrov/coaching/pull/1/files#r10781564>
> .
>