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

Restricted Arrays #40

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

Restricted Arrays #40

wants to merge 7 commits into from

Conversation

KayKay-git
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.

Not bad Kalkidan, you hit most of the learning goals. Take a look at the feedback on the binary_search method. Let me know what questions you have on it.

Comment on lines +12 to 14
# Time complexity: 0(n) Linear: iteration depends on length, we have to go through the array until we find the termination character nil.
# Space complexity: O(1); uses constant memory, doesn't matter how big array is, we have one counter, no new data structures being created
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 +22 to 25
# Time complexity: O(n) linear, in order to print every element in array we have to go through entire array.
# Space complexity: O(1) uses constant amount of memory, prints elements in array. No matter how array changes,
# new memory is not taken up for this method.
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 +35 to 37
# Time complexity: O(n) linear, have to iterate through array until we find it.
# Space complexity: O(1), constant memory,
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 +47 to 49
# Time complexity: O(n) linear: since it's unsorted, will have to go through the entire array until the largest value is found.
# Space complexity: O(1) memory usage does not change for this method, it is constant.
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 +66 to 68
# Time complexity: O(n) linear: since it's unsorted, will have to go through the entire array until the smallest value is found.
# Space complexity: O(1) memory usage does not change for this method, it is constant.
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 85 to 88
# Time complexity: O(n) execute in linear time as compared to the size of the input
# Space complexity: O(1), since it is in place. New memory is not needed to store the reversed array.
# Amount of memory used does not change as the size of the input array changes.
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.

👍

@KayKay-git KayKay-git force-pushed the master branch 2 times, most recently from 7fdb99e to 52d9edc Compare September 22, 2020 16:27
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.

Nice

Comment on lines +107 to 109
# Time complexity: O(log n), the data set size affects the efficiency of the algorithm in a logarithmic fashion
# Space complexity: O(1), memory used does not change as the size of the input array changes
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