Skip to content

Instantly share code, notes, and snippets.

@jfraboni
Last active February 19, 2019 09:24
Show Gist options
  • Save jfraboni/12dc734c122f1dd57ea06558fd23df08 to your computer and use it in GitHub Desktop.
Save jfraboni/12dc734c122f1dd57ea06558fd23df08 to your computer and use it in GitHub Desktop.
// Quadratic time complexity O(N 2 ) — “Order N squared”
function compareAll(active) {
// loop thru all bodies backwards //
for(let i = active.length - 1; i > -1; i--) {
// pull out bodyA for comparison //
const bodyA = active[i];
// loop thru all bodies backwards again //
for(let j = active.length - 1; j > -1; j--) {
// pull out bodyB for comparison //
const bodyB = active[j];
// compare bodyA to bodyB...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment