-
Notifications
You must be signed in to change notification settings - Fork 44
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
Earth - Sophie #20
base: master
Are you sure you want to change the base?
Earth - Sophie #20
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.
These methods look good Sophie. You hit the learning goals here. Well done.
# 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.
👍
# if head is nil | ||
return @head = Node.new(value) if @head.nil? | ||
|
||
# if head contains data | ||
new_node = Node.new(value) | ||
new_node.next = @head | ||
@head = new_node | ||
return @head |
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 head is nil | |
return @head = Node.new(value) if @head.nil? | |
# if head contains data | |
new_node = Node.new(value) | |
new_node.next = @head | |
@head = new_node | |
return @head | |
@head = Node.new(value, @head) |
# Time Complexity: o(n) | ||
# Space Complexity: o(1) | ||
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.
👍
# Time Complexity: o(n) | ||
# Space Complexity: o(1) | ||
def find_max |
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.
👍
# Time Complexity: o(n) | ||
# Space Complexity: o(1) | ||
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.
👍
# Time Complexity: o(1) | ||
# Space Complexity: o(1) | ||
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.
👍
# Time Complexity: ? | ||
# Space Complexity: ? | ||
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.
👍 Time complexity O(n) and space complexity O(1)
# Time Complexity: o(n) | ||
# Space Complexity: o(1) | ||
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.
👍
# Time Complexity: o(n) | ||
# Space Complexity: o(1) | ||
def get_at_index(index) |
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.