Created
October 25, 2017 03:48
-
-
Save michaelablackham/2b85786d0487c8bf8390b10d93244648 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
1. even or odd | |
- constant time | |
- because it involves one number and just returns a true or false | |
- based on one input - not running through an array | |
2. Are you there? | |
- polynomial O(n^2) | |
- loops within loops (2 loops so 2 is the exponent) | |
3. Doubler | |
- linear O(n) | |
- based directly on whatever the input is for the amount of if/els it needs | |
- one simple for loop | |
4. Naive search | |
- linear O(n) | |
- based directly on whatever the input is for the amount of if/els it needs | |
- one simple for loop | |
5. Creating pairs | |
- polynomial O(n^2) | |
- loops within loops (2 loops so 2 is the exponent) | |
6. Fibonacci | |
- linear O(n) | |
- based directly on whatever the input is for the amount of if/els it needs | |
7. Efficient search | |
- logarithmic O(log(n)) | |
- cuts the content / 2 | |
- uses while loop | |
8. Rando element | |
- constant time | |
- no looping | |
- works with just 1 input | |
9. Prime #? | |
- constant time XXXXX turned out to be wrong - this is linear - directly proportional to the input | |
- true /false output | |
- based on integer in depends on the amount of time it takes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment