Last active
February 19, 2019 09:24
-
-
Save jfraboni/12dc734c122f1dd57ea06558fd23df08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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