Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

RuthieRNewman
Copy link

Dynamic Programming

Copy link

@CheezItMan CheezItMan left a 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.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.
"""

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants