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

submitting currently solved methods - marj #46

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

Conversation

Schmarj3
Copy link

No description provided.

Copy link
Collaborator

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

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.

Comment on lines +9 to 11
# 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)
Copy link
Collaborator

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.

Comment on lines +21 to 23
# 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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ You are not printing each element and if you test this method you won't get a nice printout of the array contents.

You need a loop like length.

Comment on lines +29 to 31
# 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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Comment on lines +46 to 48
# 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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Comment on lines +60 to 62
# 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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Comment on lines +73 to 75
# 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)
Copy link
Collaborator

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.

Comment on lines +97 to 99
# 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)
Copy link
Collaborator

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.

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