you forgot to find the MOM element by recursivly calling the select at line 58. You are simply getting hte middle of medians instead of median of medians
"v = (x.length%2 == 0)? x[x.length%2-1]: x[x.length/2];" will always produce an error when the boolean part evaluates to true. Are you sure you didn't mean "v = (x.length%2 == 0)? x[x.length/2-1]: x[x.length/2];"?
you forgot to find the MOM element by recursivly calling the select at line 58. You are simply getting hte middle of medians instead of median of medians
ReplyDelete"v = (x.length%2 == 0)? x[x.length%2-1]: x[x.length/2];"
ReplyDeletewill always produce an error when the boolean part evaluates to true. Are you sure you didn't mean
"v = (x.length%2 == 0)? x[x.length/2-1]: x[x.length/2];"?