Open
Conversation
CheezItMan
reviewed
Sep 22, 2020
Collaborator
CheezItMan
left a comment
There was a problem hiding this comment.
Well done Anna, you hit the learning goals here. Nice work!
Comment on lines
+15
to
20
| # Complexity assessment: | ||
| # Note: where n = length of the input array | ||
| # Time complexity: O(n); linear; at most will parse through each array elem once | ||
| # Space complexity: O(1); constant; excluding the input space, | ||
| # the variables included in the function are all constants | ||
| def length(array) |
Comment on lines
+41
to
45
| # Complexity assessment: | ||
| # Note: where n = length of the input array | ||
| # Time complexity: O(n); linear; prints each elem of array | ||
| # Space complexity: O(1); constant; space for index (int) | ||
| def print_array(array) |
Comment on lines
+59
to
63
| # Complexity assessment: | ||
| # Note: where n = length of the input array | ||
| # Time complexity: O(n); linear; worst case goes through array from beginning to end to find value | ||
| # Space complexity: O(1); constant; doesn't require more space than input array and index constant | ||
| def search(array, length, value_to_find) |
Comment on lines
+81
to
85
| # Complexity assessment: | ||
| # Note: where n = length of the input array | ||
| # Time complexity: O(n); linear; worst case will parse through array from beginning to end to find max | ||
| # Space complexity: O(1); constant; does not require new vars aside from index (int) and max value (int) | ||
| def find_largest(array, length) |
Comment on lines
+105
to
109
| # Complexity assessment: | ||
| # Note: where n = length of the input array | ||
| # Time complexity: O(n); linear; worst case will parse through array from beginning to end to find min | ||
| # Space complexity: O(1); constant; does not require new vars aside from index (int) and min value (int) | ||
| def find_smallest(array, length) |
Comment on lines
+128
to
132
| # Complexity assessment: | ||
| # Note: where n = length of the input array | ||
| # Time complexity: O(n); linear; traverse through half of array O(n/2) --> O(n) | ||
| # Space complexity: O(1); constant; does not require new vars aside from index (int) and reverse_ind (int) | ||
| def reverse(array, length) |
Comment on lines
+153
to
158
| # Complexity assessment: | ||
| # Note: where n = length of the input array | ||
| # Time complexity: O(log n); logarithmic; half of array is eliminated with each search: | ||
| # doubling size of array only increases search count by 1 | ||
| # Space complexity: O(1); constant; does not require new vars aside from begin_ind (int), end_ind (int), and midpoint (int) | ||
| 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.