Skip to content

Conversation

@steve-messing
Copy link

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.

These methods look good Sophie. You hit the learning goals here. Well done.

Comment on lines +21 to 23
# 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 +25 to +32
# 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

Choose a reason for hiding this comment

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

Suggested change
# 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)

Comment on lines +37 to 39
# 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 +52 to 54
# Time Complexity: o(n)
# Space Complexity: o(1)
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 +73 to 75
# 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 +95 to 97
# Time Complexity: o(1)
# Space Complexity: o(1)
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 102 to 104
# 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.

👍 Time complexity O(n) and space complexity O(1)

Comment on lines +119 to 121
# Time Complexity: o(n)
# Space Complexity: o(1)
def length

Choose a reason for hiding this comment

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

👍

Comment on lines +135 to 137
# Time Complexity: o(n)
# Space Complexity: o(1)
def get_at_index(index)

Choose a reason for hiding this comment

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

👍

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