Skip to content

Conversation

@vwhwang
Copy link

@vwhwang vwhwang commented Aug 24, 2020

No description provided.

Copy link

@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.

Well done, take a look at my comments and let me know what questions you have.

Comment on lines +24 to 26
# Time Complexity: O(1)
# Space Complexity: O(1)
def add_first(value)

Choose a reason for hiding this comment

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

👍

Comment on lines +27 to +33
if @head.nil?
@head = @tail = Node.new(value)
else
new_node = Node.new(value,@head)
@head.previous = new_node
@head = new_node
end

Choose a reason for hiding this comment

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

This can be simplified a bit

Suggested change
if @head.nil?
@head = @tail = Node.new(value)
else
new_node = Node.new(value,@head)
@head.previous = new_node
@head = new_node
end
@head = Node.new(value, @head)

Comment on lines +38 to 40
# Time Complexity: O(n)
# Space Complexity: O(1)
def search(value)

Choose a reason for hiding this comment

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

👍

Comment on lines 57 to 59
# method to return the max value in the linked list
# returns the data value and not the node
def find_max

Choose a reason for hiding this comment

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

👍

Comment on lines +75 to 77
# Time Complexity: O(n)
# Space Complexity: O(1)
def find_min

Choose a reason for hiding this comment

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

👍

Comment on lines 175 to 177
# Time Complexity: ?
# Space Complexity: ?
def reverse

Choose a reason for hiding this comment

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

👍 Space and time complexity?

Comment on lines +202 to 204
# Time Complexity: O(n)
# Space Complexity: O(1)
def find_nth_from_end(n)

Choose a reason for hiding this comment

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

👍

Comment on lines 237 to 239
# Time Complexity: ?
# Space Complexity: ?
def get_first

Choose a reason for hiding this comment

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

👍

Comment on lines 244 to 247
# method that inserts a given value as a new last node in the linked list
# Time Complexity: ?
# Space Complexity: ?
def add_last(value)

Choose a reason for hiding this comment

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

👍 , space and time complexity?

Comment on lines 265 to 269
# method that returns the value of the last node in the linked list
# returns nil if the linked list is empty
# Time Complexity: ?
# Space Complexity: ?
def get_last

Choose a reason for hiding this comment

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

👍 , space and time complexity?

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