c - Can this "attack" really cause quicksort to degrade to quadratic running time even if items had been randomly shuffled? -
Claims a method to reduce any acceleration implementation in the quadratic time. I think it means that it will always prepare a list that always takes O (N ^ 2) to run. This is saying something because, although the worst case of qucort is O (N ^ 2), which usually runs O (Namrog). The author claims that it still works when the array is randomly rotated before calling Christost, how is it possible? I do not know C but this is something else and code of the program
QUICKTORT will be only vulnerable provided it meets some light assumptions which have come from every implementation that I have seen : 1. Implementation is single-threaded. 2. Pivit-choosing o (1) takes comparison; All other comparisons are for split. 3. Comparison of division phase is consistent and includes pivot value. 4. Comparing and copying the only data operation performed. 5. Comparison only includes input data values or copies.
#include & lt; Stdlib.h & gt; Int * val; / * Item Value * / Int NCMP; / Number of Components * / Ent NSiLID; / Number of solid items * / integer candidates; / * Poor candidate * / int gas; / * Gas value * / # defined freeze (x) val [x] = nsolid ++ int cmp (constants void * px, const void * py) / * per c standard * / {const int x = * (const int * ) Px; Const int y = * (const int *) py; NCMP ++; If (val [x] == gas and wall [y] == gas) {if (x == candidate) freeze (x); And Freeze (Y); } If (val [x] == gas) candidate = x; Else if (val [y] == gas) candidate = y; Return Val [x] - Well [y]; / * Only Sense cases *}} int antiqsort (int n, int * a) {int i; Int * ptr = malloc (n * sizeof (* ptr)); Val = a; Gas = N-1; Nsolid = ncmp = Candidate = 0; For (i = 0; i & lt; n; i ++) {ptr [i] = i; Val [i] = gas; } Qsort (ptr, n, sizeof (* ptr), cmp); Free (PTR); Return NCMP; }
Normal method works against any implementation - quicksort- even a random - satisfies some very light and realistic assumptions .
Does randomizing random selection or input structure make random?
The model uses the model assumes that the attacker is not only data control, but rather the comparison function. Essentially, the comparison function is about the data, showing that the quarters were always meant to select a horrible spindle. It has very powerful ability for the opponent.
Comments
Post a Comment