-
Notifications
You must be signed in to change notification settings - Fork 48
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
Time - Haben #35
base: master
Are you sure you want to change the base?
Time - Haben #35
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.
Overall well done, but you submitted the TREE assignment instead of this one. When you get it turned in, I'll change the mark.
Take a look at my comments and let me know what questions you have.
# Time Complexity:O(1) | ||
# Space Complexity:O(1) | ||
def add_first(value) |
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.
👍
# Space Complexity: ? | ||
def find_min | ||
raise NotImplementedError | ||
while (current = current.next) |
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.
Clever use of the =
sign here.
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def search(value) |
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.
👍 , the space complexity is O(1)
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def find_min |
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.
👍 , the space complexity is O(1) because you're not creating a new list.
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def 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.
👍 , the space complexity is O(1) because you're not creating a new list.
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def delete(value) |
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.
👍 , the space complexity is O(1) because you're not creating a new list.
# Time Complexity: o(n) | ||
# Space Complexity: O(n) | ||
# def reverse | ||
# current = @head | ||
# while current != nil | ||
# temp = current.previous | ||
# current.previous = current.next | ||
# current.next = temp | ||
# current = current.previous | ||
# end | ||
# temp = @head | ||
# @head = @tail | ||
# @tail = temp | ||
# end | ||
|
||
def reverse |
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.
👍 , the space complexity is O(1) because you're not creating a new list.
# Time Complexity: ? | ||
# Space Complexity: ? | ||
def get_first |
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.
👍 , space & time complexity?
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def add_last(value) |
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.
👍 , Space complexity is O(1)
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def get_last |
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.
👍 , the space complexity is O(1) because you're not creating a new list.
I wasn't sure if the reverse one was optional. After trying it, I decided to skip the test as I didn't want to waste more time at the last minute.