-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruthie Newman, CS fundamentals, cohort 15, paper #49
base: master
Are you sure you want to change the base?
Conversation
…meters of left and right added to the max_sub_array method in max_subarray.py.
…ored max_sub_array method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this in Ruthie. Nicely done.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 This works, but if you use a dynamic programming approach you can get it done in O(n) time complexity.
Dynamic Programming