8

cool algorithm I implemented today to calculate Median in my statistics program.

Comments
  • 2
    I don't get it. Was this code written by some sort of genetic algorithm that converged on this local minima?
  • 1
    @ronakkaria lol it simply finds the median/middle of a sequence of numbers
  • 4
    @merge-conflict why the for loop in the even case? It's not doing anything. Just like a vestigial organ.
  • 1
    I don't get the for loop either. 😔
  • 1
    @ronakkaria oh okay I see what you mean 😁
  • 2
    What if data in your array aren't sorted?
    *Grab popcorn
  • 3
    Instead of the for loop use a while(true). Not only does it do anything like the for loop, but it's more stylish!
  • 3
    @7Raiden
    Or you can use my favourite
    #define ever ;;
    for(ever);

    But to make it work the same way as in the code presented by OP you will need to break; inside if() and increment i inside condition.
  • 1
    Oh my bad..
  • 1
    Thank guys..
Add Comment