Opinions
-
It is kinda amazing, isn't it? The
y[iarray]
thing, I've seen in a few different websites, basically the compiler just expands it to*(y + iarray)
which is the same asiarray[y]
and it carries on its merry way. The O(n^2) complexity is hidden in the single loop, I reset the values of x and y in the conditional (they=x&=~x
bit) when y gets past the array length and x is non-zero. Pretty near impossible to prove n^2 runtime, or to prove correctness, or even to prove that it terminates, but it's fun and it works. I thought about writing some more sorts like this, but haven't gotten to it...SirTimothy wrote:
the compiler just expands it to *(y + iarray) which is the same as iarray[y]
It relies on a C-specific feature, where size of
int
is the same as size of an address, doesn't it? In C#int
is always a 32-bit integer... I suppose proving n^2 runtime isn't hard. Each obfuscation can be transformated to a more readable form, which is fully equivalent. Step by step, one could get something similar to my code posted above. I suppose. Sometimes when I have a trouble with theory I generate a chart and write "The chart says, that the algorithm is quadratic, isn't it?". Unfortunately not every teacher was satisfied with such report... :rolleyes:Greetings - Jacek
-
That, of course, is so that I can change the function name, and only need to change one place where it's used. Gotta think about maintainability and future modifications!
... maintainability and future modifications ... hahaha very funny! Can you tell us why you wrote this code? Are you a teacher showing "bad practice"? If one of my programmers would come up with a piece of code like this -> :thumbsdown:
-
... maintainability and future modifications ... hahaha very funny! Can you tell us why you wrote this code? Are you a teacher showing "bad practice"? If one of my programmers would come up with a piece of code like this -> :thumbsdown:
Nah, not a teacher. Actually, just graduated from university. Why'd I write it? Bored, felt like taking some reasonably clean code and totally butchering it, thought I'd see how ugly I could make it :) Of course, it could be much worse, but whatever, it was fun!
-
It is kinda amazing, isn't it? The
y[iarray]
thing, I've seen in a few different websites, basically the compiler just expands it to*(y + iarray)
which is the same asiarray[y]
and it carries on its merry way. The O(n^2) complexity is hidden in the single loop, I reset the values of x and y in the conditional (they=x&=~x
bit) when y gets past the array length and x is non-zero. Pretty near impossible to prove n^2 runtime, or to prove correctness, or even to prove that it terminates, but it's fun and it works. I thought about writing some more sorts like this, but haven't gotten to it...