Open
Conversation
…ind_smallest, reverse and binary_search.
CheezItMan
reviewed
Oct 27, 2020
Collaborator
CheezItMan
left a comment
There was a problem hiding this comment.
Ana, well done. Take a look at my comment on find_smallest and let me know what questions you have there. Thanks for getting this in.
| @@ -0,0 +1,7 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
Collaborator
There was a problem hiding this comment.
I suggest you add .idea to your .gitignore file.
| i += 1 | ||
| end | ||
| return i | ||
| end |
Collaborator
There was a problem hiding this comment.
Suggested change
| end | |
| end |
Comment on lines
+10
to
13
| # Time complexity: Linear or O(n) --> it will iterate over each of the elements inside array. As the input grows, the greater the amount of time it takes to perform the function. | ||
| # Space complexity: Constant of O(1) --> we only create one new variable and it doesnt depend on the size of the array. | ||
|
|
||
| def length(array) |
Comment on lines
+22
to
24
| # Time complexity: Linear or O(n) --> it will iterate over each of the elements inside array. As the input grows, the greater the amount of time it takes to perform the function. | ||
| # Space complexity: Constant of O(1) -> only one variable is created and its used throughout the entire function. | ||
| def print_array(array) |
Comment on lines
+35
to
37
| # Time complexity: Linear or O(n) --> it will need to iterate over all elements in worse case, which means it will grow through each iteration. | ||
| # Space complexity: Constant or O(1) | ||
| def search(array, length, value_to_find) |
Comment on lines
+50
to
52
| # Time complexity: Linear or O(n) | ||
| # Space complexity: Constant or O(1) | ||
| def find_largest(array, length) |
Comment on lines
+81
to
83
| # Time complexity: Linear or O(n) | ||
| # Space complexity: Constant or O(1) | ||
| def reverse(array, length) |
| # Space complexity: Constant of O(1) - two variables are created and are used throughout the function | ||
| def find_smallest(array, length) | ||
| raise NotImplementedError | ||
| min = 0 |
Collaborator
There was a problem hiding this comment.
If the array has positive numbers starting min at 0, will cause these to fail.
Suggested change
| min = 0 | |
| min = array[0] |
Comment on lines
+96
to
98
| # Time complexity: Logarithmic or O(log n) - I remembered from lessons that binary search is 0(log n) | ||
| # Space complexity: Constant or O(1)? | ||
| 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.