Image

Imagebattie42 wrote in Imagejava_dev 😡frustrated

The math behind sort methods

Hi again. I'm having a bit of trouble understanding my current programming project. I have to test out different sort methods by finding the times it takes to sort arrays ordered in different ways with varying number of integers. Then I make tables and graphs the results in a bajillion different ways.

That's all fine, if not agonizingly tedious. But next I have to discuss something my professor calls the Big O of the sorts. This is where I'm getting hung up. I have three sorts on the order of N^2 : Bubble, Selection Exchange, and Insertion. I also have three on the order of N*Ln(N). Then there is the shell sort, which apparently is something else entirely.

So far I learned that the the N^2 searches require a good long novel to sit through, while the NlnN sorts are nice and fast. What I don't understand is why. I tried going through the code for the sorts, but it's written in a different syntax so I can't really understand it. I also don't understand how to tell what the order is (and since I can't read the code, how can I)?

If anything I just said made any sense, could someone give me a hint? I'd really appreciate it.