Open
Conversation
CheezItMan
reviewed
Sep 22, 2020
Collaborator
CheezItMan
left a comment
There was a problem hiding this comment.
Not bad Kalkidan, you hit most of the learning goals. Take a look at the feedback on the binary_search method. Let me know what questions you have on it.
Comment on lines
+12
to
14
| # Time complexity: 0(n) Linear: iteration depends on length, we have to go through the array until we find the termination character nil. | ||
| # Space complexity: O(1); uses constant memory, doesn't matter how big array is, we have one counter, no new data structures being created | ||
| def length(array) |
Comment on lines
+22
to
25
| # Time complexity: O(n) linear, in order to print every element in array we have to go through entire array. | ||
| # Space complexity: O(1) uses constant amount of memory, prints elements in array. No matter how array changes, | ||
| # new memory is not taken up for this method. | ||
| def print_array(array) |
Comment on lines
+35
to
37
| # Time complexity: O(n) linear, have to iterate through array until we find it. | ||
| # Space complexity: O(1), constant memory, | ||
| def search(array, length, value_to_find) |
Comment on lines
+47
to
49
| # Time complexity: O(n) linear: since it's unsorted, will have to go through the entire array until the largest value is found. | ||
| # Space complexity: O(1) memory usage does not change for this method, it is constant. | ||
| def find_largest(array, length) |
Comment on lines
+66
to
68
| # Time complexity: O(n) linear: since it's unsorted, will have to go through the entire array until the smallest value is found. | ||
| # Space complexity: O(1) memory usage does not change for this method, it is constant. | ||
| def find_smallest(array, length) |
Comment on lines
+85
to
88
| # Time complexity: O(n) execute in linear time as compared to the size of the input | ||
| # Space complexity: O(1), since it is in place. New memory is not needed to store the reversed array. | ||
| # Amount of memory used does not change as the size of the input array changes. | ||
| def reverse(array, length) |
7fdb99e to
52d9edc
Compare
CheezItMan
reviewed
Dec 6, 2020
Comment on lines
+107
to
109
| # Time complexity: O(log n), the data set size affects the efficiency of the algorithm in a logarithmic fashion | ||
| # Space complexity: O(1), memory used does not change as the size of the input array changes | ||
| 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.