-
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
Array Exercise-First go. #37
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.
Nice work Blaine, you hit the learning goals here. Well done.
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
👍
# Prints each integer values in the array | ||
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
👍
# For an unsorted array, searches for 'value_to_find'. | ||
# Returns true if found, false otherwise. | ||
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
👍
# Finds and returns the largest integer value the array | ||
# Assumes that the array is not sorted. | ||
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
👍
if array[i] > largest_value | ||
largest_value = array[i] | ||
end |
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.
if array[i] > largest_value | |
largest_value = array[i] | |
end | |
if array[i] > largest_value | |
largest_value = array[i] | |
end |
i += 1 | ||
end | ||
return largest_value | ||
# raise NotImplementedError | ||
end | ||
|
||
# Finds and returns the smallest integer value in the array | ||
# Assumes that the array is not sorted. | ||
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
👍
i += 1 | ||
end | ||
return smallest_value | ||
# raise NotImplementedError | ||
end | ||
|
||
# Reverses the values in the integer array in place | ||
# Time complexity: ? | ||
# Space complexity: ? | ||
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.
👍
if array[low] == value_to_find | ||
return true | ||
end | ||
return false | ||
# raise NotImplementedError |
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.
Some boolean Zen.
if array[low] == value_to_find | |
return true | |
end | |
return false | |
# raise NotImplementedError | |
return array[low] == value_to_find |
rev -= 1 | ||
end | ||
return array | ||
# raise NotImplementedError | ||
end | ||
|
||
# For an array sorted in ascending order, searches for 'value_to_find'. | ||
# Returns true if found, false otherwise. | ||
# Time complexity: ? | ||
# Space complexity: ? | ||
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.