Arrays exercise submission @ Water class-Hanh Solo#36
Open
seattlefurby17 wants to merge 2 commits intoAda-C14:masterfrom
Open
Arrays exercise submission @ Water class-Hanh Solo#36seattlefurby17 wants to merge 2 commits intoAda-C14:masterfrom
seattlefurby17 wants to merge 2 commits intoAda-C14:masterfrom
Conversation
CheezItMan
reviewed
Sep 22, 2020
Collaborator
CheezItMan
left a comment
There was a problem hiding this comment.
Well done Hahn, you hit the learning goals here. Nice work.
Comment on lines
+9
to
14
| # Time complexity: There is only one while loop where we iterate over each | ||
| # element of the array. Time complexity will be O(n) time where n is how many | ||
| # times the loop will execute. | ||
| # Space complexity: The method used one local integer variable | ||
| # no matter the input size, so the space complexity is constant or O(1). | ||
| def length(array) |
Comment on lines
+25
to
29
| # Time complexity: There is only one while loop where we iterate over each | ||
| # element of the array. Time complexity will be n time where n is how many | ||
| # times the loop will execute. | ||
| # Space complexity: constant or O(1) | ||
| def print_array(array) |
Comment on lines
+39
to
43
| # Time complexity:O(n) There is only one while loop where we iterate over each | ||
| # element of the array. Time complexity will be n time where n is how many | ||
| # times the loop will execute. | ||
| # Space complexity: constant or O(1) | ||
| def search(array, length, value_to_find) |
Comment on lines
+62
to
68
| # Time complexity:This method will iterate through the entire array. Thus if the | ||
| # array size doubles the loop will take twice as long. So the time complexity is O(n) | ||
| # Space complexity: This method only creates two additional variables, | ||
| # index and max which does not change no matter how large the array gets. | ||
| # Therefore the space complexity does not change as the size of the array increases. | ||
| # This means the space complexity is O(1). | ||
| def find_largest(array, length) |
Comment on lines
+84
to
90
| # Time complexity: This method will iterate through the entire array. Thus if the | ||
| # array size doubles the loop will take twice as long. So the time complexity is O(n) | ||
| # Space complexity: This method only creates two additional variables, | ||
| # index and min which does not change no matter how large the array gets. | ||
| # Therefore the space complexity does not change as the size of the array increases. | ||
| # This means the space complexity is O(1). | ||
| def find_smallest(array, length) |
Comment on lines
+105
to
109
| # Time complexity:O(n) this method only iterate through half of the array however | ||
| # it is depends on the size of the input. The longer the array, the longer it takes or | ||
| # linear complexity. | ||
| # Space complexity: constant | ||
| def reverse(array, length) |
Comment on lines
+128
to
134
| # Time complexity: Log2 n means at each step the value reduces by half of the remaining. | ||
| # It also means that as the size of the array doubles, | ||
| # the number of iterations only increases by 1. | ||
| # The main loop in binary search runs log2 n number of times where | ||
| # n is the number of elements in the input array. | ||
| # Space complexity: constant | ||
| def binary_search(array, length, value_to_find) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.