Created
July 12, 2019 04:03
-
-
Save RyanCahela/8c59b83b403672b4b16ea2b1ef21d9a9 to your computer and use it in GitHub Desktop.
Revisions
-
RyanCahela created this gist
Jul 12, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ // Big O Questions // 1. // 1) constant O(1) // 2) linear O(n) // 2. // constant because the size of the in put doesn't change the time complexity. // 3. ************ // O(a * b) // because the function has 2 inputs that can be of varying value. // 4. // O(n) // because the for loop had to operate on every item in the array. // 5. // O(n) // because the if statement is constant it gets dropped for the for loop. // 6. // O(n^2) // because nested for loops operating on the same input. // 7. // O(n) // because the array operations are all push, // they get dropped and the linear time complexity of the for loop is left. // 8. // O(logN) // because it splits the array in half with every loop. // 9. // O(1) // constant time. because array item look up is constant. // 10. // O(n) // worst case the for loop would have to loop N times. // 11. //13 // 1) O(n) //because larger num of sheep the more operations. // 2) O(n) //because larger input means funciton calls itself more.