-
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
Fire - Anna #28
base: master
Are you sure you want to change the base?
Fire - Anna #28
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 done Anna, you hit the learning goals here. Nice work!
# Complexity assessment: | ||
# Note: where n = length of the input array | ||
# Time complexity: O(n); linear; at most will parse through each array elem once | ||
# Space complexity: O(1); constant; excluding the input space, | ||
# the variables included in the function are all constants | ||
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.
👍
# Complexity assessment: | ||
# Note: where n = length of the input array | ||
# Time complexity: O(n); linear; prints each elem of array | ||
# Space complexity: O(1); constant; space for index (int) | ||
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.
👍
# Complexity assessment: | ||
# Note: where n = length of the input array | ||
# Time complexity: O(n); linear; worst case goes through array from beginning to end to find value | ||
# Space complexity: O(1); constant; doesn't require more space than input array and index constant | ||
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.
👍
# Complexity assessment: | ||
# Note: where n = length of the input array | ||
# Time complexity: O(n); linear; worst case will parse through array from beginning to end to find max | ||
# Space complexity: O(1); constant; does not require new vars aside from index (int) and max value (int) | ||
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.
👍
# Complexity assessment: | ||
# Note: where n = length of the input array | ||
# Time complexity: O(n); linear; worst case will parse through array from beginning to end to find min | ||
# Space complexity: O(1); constant; does not require new vars aside from index (int) and min value (int) | ||
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.
👍
# Complexity assessment: | ||
# Note: where n = length of the input array | ||
# Time complexity: O(n); linear; traverse through half of array O(n/2) --> O(n) | ||
# Space complexity: O(1); constant; does not require new vars aside from index (int) and reverse_ind (int) | ||
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.
👍
# Complexity assessment: | ||
# Note: where n = length of the input array | ||
# Time complexity: O(log n); logarithmic; half of array is eliminated with each search: | ||
# doubling size of array only increases search count by 1 | ||
# Space complexity: O(1); constant; does not require new vars aside from begin_ind (int), end_ind (int), and midpoint (int) | ||
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.
👍
No description provided.