-
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
submitting currently solved methods - marj #46
base: master
Are you sure you want to change the base?
Conversation
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.
Well Marj, you have most of the methods working except for print and binary search, so you hit most of the learning goals here. Not bad.
# Time complexity: Time complexity is O(1) because the arry has a fixed length of 20 | ||
# Space complexity: I think also O(1) since it is a fixed amount that it can hold | ||
def length(array) |
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.
👍 Although the time complexity is O(n) because you have to travel the length of the array and it will vary by array size.
# Time complexity: if array length does not got past 20, o(1), but if it increases o(n) because the more/less values the more/less time to process | ||
# Space complexity: pretty much the same as above, there are no new values added past 20 or new arrays created | ||
def print_array(array) |
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.
You need a loop like length.
# Time complexity: o(n) because it's not sorted so the more values it has to go through to find a specific value, the longer it takes | ||
# Space complexity: o(1) just sorting and not adding values | ||
def search(array, length, value_to_find) |
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.
👍
# Time complexity: for each value that is not the largest value, the more time it will take - o(n) | ||
# Space complexity: no new arrays - o(1) | ||
def find_largest(array, length) |
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.
👍
# Time complexity: same as for largest integer in unsorted array - or each value that is not the largest value, the more time it will take - o(n) | ||
# Space complexity: same - no new arrays - o(1) | ||
def find_smallest(array, length) |
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.
👍
# Time complexity: for set length O(1), for any array length O(n) | ||
# Space complexity: O(1) because reverses in place, no new array is made | ||
def reverse(array, length) |
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.
👍 Although the time complexity is O(n) because you have to travel half the length of the array and it will vary by array size.
# Time complexity: o(nlog n) - since doing the opposite of loop and cutting array in half | ||
# Space complexity: o(1) since no new array is being created | ||
def binary_search(array, length, value_to_find) |
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.
Looks like you have a good start, just not a finished result.
No description provided.