Skip to content

Earth - Sophie - #20

Open
steve-messing wants to merge 2 commits into
Ada-C14:masterfrom
steve-messing:master
Open

Earth - Sophie#20
steve-messing wants to merge 2 commits into
Ada-C14:masterfrom
steve-messing:master

Conversation

@steve-messing

Copy link
Copy Markdown

No description provided.

@CheezItMan CheezItMan left a comment

Copy link
Copy Markdown

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 thread lib/linked_list.rb
Comment on lines +21 to 23
# Time Complexity: o(1)
# Space Complexity: o(1)
def add_first(value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/linked_list.rb
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

Copy link
Copy Markdown

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 thread lib/linked_list.rb
Comment on lines +37 to 39
# Time Complexity: o(n)
# Space Complexity: o(1)
def search(value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/linked_list.rb
Comment on lines +52 to 54
# Time Complexity: o(n)
# Space Complexity: o(1)
def find_max

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/linked_list.rb
Comment on lines +73 to 75
# Time Complexity: o(n)
# Space Complexity: o(1)
def find_min

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/linked_list.rb
Comment on lines +95 to 97
# Time Complexity: o(1)
# Space Complexity: o(1)
def get_first

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/linked_list.rb
Comment on lines 102 to 104
# Time Complexity: ?
# Space Complexity: ?
def add_last(value)

Copy link
Copy Markdown

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 thread lib/linked_list.rb
Comment on lines +119 to 121
# Time Complexity: o(n)
# Space Complexity: o(1)
def length

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/linked_list.rb
Comment on lines +135 to 137
# Time Complexity: o(n)
# Space Complexity: o(1)
def get_at_index(index)

Copy link
Copy Markdown

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