Skip to content

Conversation

@natalia-ku
Copy link

Restricted Array

Congratulations! You're submitting your assignment.

Comprehension Questions

What is the time and space complexity for each method you implemented? Provide justification.

Question Answer
What is the time complexity of the length method? Provide justification. O(n), each element visited once
What is the space complexity of the length method? Provide justification. O(1), only one variable is used
What is the time complexity of the print_array method? Provide justification. O(n), each element visited once
What is the space complexity of the print_array method? Provide justification. O(1), only one variable is used
What is the time complexity of the reverse method? Provide justification. O(n), each element visited once
What is the space complexity of the reverse method? Provide justification. O(1), additional space allocation is independent from size of array
What is the time complexity of the search method? Provide justification. O(n), each element visited once
What is the space complexity of the search method? Provide justification. O(1), additional storage allocation is independent from size of array
What is the time complexity of the delete method? Provide justification. O(n), each element visited once
What is the space complexity of the delete method? Provide justification. O(1), additional storage allocation is independent from size of array
What is the time complexity of the empty method? Provide justification. O(n), each element visited once
What is the space complexity of the empty method? Provide justification. O(1), additional storage allocation is independent from size of array
What is the time complexity of the find_largest method? Provide justification. O(n), each element visited once
What is the space complexity of the find_largest method? Provide justification. O(1), additional storage allocation is independent from size of array
What is the time complexity of the insert_ascending method? Provide justification. O(n), each element visited once
What is the space complexity of the insert_ascending method? Provide justification. O(1), additional storage allocation is independent from size of array

# Prints each integer values in the array
def print_array(array)
puts "NOT IMPLEMENTED"
(0..array.array_size).each do |i|
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although, array_size was intentionally kept private, you do have access to the length method that you just implemented. :-)

@shrutivanw
Copy link
Collaborator

👍 Nicely done! :)

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