Open
Conversation
CheezItMan
reviewed
Sep 22, 2020
Collaborator
CheezItMan
left a comment
There was a problem hiding this comment.
Well done, you hit all the learning goals here. Take a look at my comment about reverse. Otherwise nice work!
Comment on lines
+9
to
11
| # Time complexity: O(n) | ||
| # Space complexity: O(1) | ||
| def length(array) |
Comment on lines
+22
to
24
| # Time complexity: O(n) | ||
| # Space complexity: O(1) | ||
| def print_array(array) |
Comment on lines
+35
to
39
| # Time complexity: | ||
| # sorted: O(n) | ||
| # unsorted: O(n) | ||
| # Space complexity: O(1) | ||
| def search(array, length, value_to_find) |
Comment on lines
+55
to
59
| # Time complexity: | ||
| # sorted: O(1) | ||
| # unsorted: O(n) | ||
| # Space complexity: O(1) | ||
| def find_largest(array, length) |
Collaborator
There was a problem hiding this comment.
👍 Actually this algorithm is always O(n) in time complexity
Comment on lines
+80
to
84
| # Time complexity: | ||
| # sorted: O(1) | ||
| # unsorted: O(n) | ||
| # Space complexity: O(1) | ||
| def find_smallest(array, length) |
Comment on lines
+103
to
105
| # Time complexity: O(n) | ||
| # Space complexity: O(1) | ||
| def reverse(array, length) |
Collaborator
There was a problem hiding this comment.
👍 , this works but since you're making an auxiliary array it has O(n) space complexity.
Can you think of a way to do this without the other array?
Comment on lines
125
to
127
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| def binary_search(array, length, value_to_find) |
Author
|
Thank you Chris |
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.
Restricted arrays solution