Ruthie Newman, CS fundamentals, cohort 15, paper#49
Open
RuthieRNewman wants to merge 6 commits intoAda-C15:masterfrom
Open
Ruthie Newman, CS fundamentals, cohort 15, paper#49RuthieRNewman wants to merge 6 commits intoAda-C15:masterfrom
RuthieRNewman wants to merge 6 commits intoAda-C15:masterfrom
Conversation
…meters of left and right added to the max_sub_array method in max_subarray.py.
…ored max_sub_array method.
CheezItMan
reviewed
Mar 11, 2022
CheezItMan
left a comment
There was a problem hiding this comment.
Thanks for getting this in Ruthie. Nicely done.
Comment on lines
2
to
+8
| def newman_conway(num): | ||
| """ Returns a list of the Newman Conway numbers for the given value. | ||
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(n) because the number of calculations performed depends on the size of num. | ||
|
|
||
| Space Complexity: Space complexity is also O(n) becuase newman_conway_nums array to store sequence values, | ||
| nm_sequence_without_leading_zero to store result with leading 0 removed and result a array to which the properly | ||
| formatted result is saved are created and the amount of space that they occupy will depend on the size of the given num. |
Comment on lines
+31
to
41
| def max_sub_array(nums, left=0, right=None): | ||
| """ Returns the max subarray of the given list of numbers. | ||
| Returns 0 if nums is None or an empty list. | ||
| Time Complexity: ? | ||
| Space Complexity: ? | ||
|
|
||
| Time Complexity: Time complexity is O(nLogn) time because of the implementation of a Divide and Conquer approach, in which the max subarray of | ||
| the given array is found through comparing the left and right value of a recursively calculated mid-point. This method also recursively calls the | ||
| helper method; max_mid_array() which considers max subarrays that range from left to right across the mid-point, with an O(nLogn) time complexity. | ||
|
|
||
| Space Complexity: Space complexity should be O(nLogn) as well because, according to my research, space complexity is relative to the size of the | ||
| call stack, which decreases by 2 values with each recursive call. | ||
| """ |
There was a problem hiding this comment.
👍 This works, but if you use a dynamic programming approach you can get it done in O(n) time complexity.
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.
Dynamic Programming