Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Opinions

Opinions

Scheduled Pinned Locked Moved The Weird and The Wonderful
data-structuresquestiondiscussionloungelearning
24 Posts 16 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S SirTimothy

    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 as iarray[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 (the y=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...

    L Offline
    L Offline
    Lutoslaw
    wrote on last edited by
    #21

    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

    1 Reply Last reply
    0
    • S SirTimothy

      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!

      J Offline
      J Offline
      johannesnestler
      wrote on last edited by
      #22

      ... 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:

      S 1 Reply Last reply
      0
      • J johannesnestler

        ... 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:

        S Offline
        S Offline
        SirTimothy
        wrote on last edited by
        #23

        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!

        1 Reply Last reply
        0
        • S SirTimothy

          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 as iarray[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 (the y=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...

          E Offline
          E Offline
          Euhemerus
          wrote on last edited by
          #24

          I think you've got way too much time on your hands :laugh:

          There is only one satisfying way to boot a computer.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups