Earth - Sophie - #20
Open
steve-messing wants to merge 2 commits into
Open
Conversation
added 2 commits
March 18, 2021 21:13
CheezItMan
reviewed
Mar 24, 2021
CheezItMan
left a comment
There was a problem hiding this comment.
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) |
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 |
There was a problem hiding this comment.
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) |
Comment on lines
+52
to
54
| # Time Complexity: o(n) | ||
| # Space Complexity: o(1) | ||
| def find_max |
Comment on lines
+73
to
75
| # Time Complexity: o(n) | ||
| # Space Complexity: o(1) | ||
| def find_min |
Comment on lines
+95
to
97
| # Time Complexity: o(1) | ||
| # Space Complexity: o(1) | ||
| def get_first |
Comment on lines
102
to
104
| # Time Complexity: ? | ||
| # Space Complexity: ? | ||
| def add_last(value) |
There was a problem hiding this comment.
👍 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 |
Comment on lines
+135
to
137
| # Time Complexity: o(n) | ||
| # Space Complexity: o(1) | ||
| def get_at_index(index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.