Skip to content

Commit

Permalink
eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
msn0 committed May 19, 2017
1 parent 0f54d8c commit 4b2f21a
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
function swap(data, i, j) {
if (i === j) {
return;
}
const tmp = data[j];
data[j] = data[i];
data[i] = tmp;
if (i === j) {
return;
}
const tmp = data[j];
data[j] = data[i];
data[i] = tmp;
}

function partition(data, start, end) {
let i, j;
for (i = start + 1, j = start; i < end; i++) {
if (data[i] < data[start]) {
swap(data, i, ++j);
let i, j;
for (i = start + 1, j = start; i < end; i++) {
if (data[i] < data[start]) {
swap(data, i, ++j);
}
}
}
swap(data, start, j);
return j;
swap(data, start, j);
return j;
}

function findK(data, start, end, k) {
while (start < end) {
let pos = partition(data, start, end);
if (pos === k) {
return data[k];
}
if (pos > k) {
end = pos;
} else {
start = pos + 1;
while (start < end) {
let pos = partition(data, start, end);
if (pos === k) {
return data[k];
}
if (pos > k) {
end = pos;
} else {
start = pos + 1;
}
}
}
}

// Calculate n-th percentile of 'data' using Nearest Rank Method
Expand Down

0 comments on commit 4b2f21a

Please sign in to comment.