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

Arrays exercise submission @ Water class-Hanh Solo #36

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

Conversation

seattlefurby17
Copy link

No description provided.

@seattlefurby17 seattlefurby17 changed the title Arrays exercise submission Arrays exercise submission @ Water class-Hanh Solo Sep 22, 2020
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 done Hahn, you hit the learning goals here. Nice work.

Comment on lines +9 to 14
# Time complexity: There is only one while loop where we iterate over each
# element of the array. Time complexity will be O(n) time where n is how many
# times the loop will execute.
# Space complexity: The method used one local integer variable
# no matter the input size, so the space complexity is constant or O(1).
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.

👍

Comment on lines +25 to 29
# Time complexity: There is only one while loop where we iterate over each
# element of the array. Time complexity will be n time where n is how many
# times the loop will execute.
# Space complexity: constant or O(1)
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.

👍

Comment on lines +39 to 43
# Time complexity:O(n) There is only one while loop where we iterate over each
# element of the array. Time complexity will be n time where n is how many
# times the loop will execute.
# Space complexity: constant or O(1)
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 +62 to 68
# Time complexity:This method will iterate through the entire array. Thus if the
# array size doubles the loop will take twice as long. So the time complexity is O(n)
# Space complexity: This method only creates two additional variables,
# index and max which does not change no matter how large the array gets.
# Therefore the space complexity does not change as the size of the array increases.
# This means the space complexity is 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 +84 to 90
# Time complexity: This method will iterate through the entire array. Thus if the
# array size doubles the loop will take twice as long. So the time complexity is O(n)
# Space complexity: This method only creates two additional variables,
# index and min which does not change no matter how large the array gets.
# Therefore the space complexity does not change as the size of the array increases.
# This means the space complexity is 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 +105 to 109
# Time complexity:O(n) this method only iterate through half of the array however
# it is depends on the size of the input. The longer the array, the longer it takes or
# linear complexity.
# Space complexity: constant
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.

👍

Comment on lines +128 to 134
# Time complexity: Log2 n means at each step the value reduces by half of the remaining.
# It also means that as the size of the array doubles,
# the number of iterations only increases by 1.
# The main loop in binary search runs log2 n number of times where
# n is the number of elements in the input array.
# Space complexity: constant
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.

👍

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