Conversation
…tead of tring to assign a list to a node
CheezItMan
reviewed
Dec 9, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work Yaz, thanks for getting this in. The methods you implementing are pretty well done. You did miss some entries for time/space complexity. Otherwise excellent work.
Comment on lines
+19
to
+23
| # method to add a new node with the specific data value in the linked list | ||
| # insert the new node at the beginning of the linked list | ||
| # Time Complexity: O(1) | ||
| # Space Complexity: O(1) | ||
| def add_first(value) |
Comment on lines
+24
to
29
| if @head | ||
| second = @head | ||
| @head = Node.new(value, second) | ||
| else | ||
| @head = Node.new(value) | ||
| end |
There was a problem hiding this comment.
Suggested change
| if @head | |
| second = @head | |
| @head = Node.new(value, second) | |
| else | |
| @head = Node.new(value) | |
| end | |
| @head = Node.new(value, @head) |
Comment on lines
+34
to
+36
| # Time Complexity: O(n) | ||
| # Space Complexity: O(1) | ||
| def search(value) |
Comment on lines
+43
to
+45
| # method to return the max value in the linked list | ||
| # returns the data value and not the node | ||
| def find_max |
Comment on lines
+62
to
+64
| # Time Complexity: O(n) | ||
| # Space Complexity: O(1) | ||
| def find_min |
Comment on lines
+121
to
+124
| # method to delete the first node found with specified value | ||
| # Time Complexity: O(n) | ||
| # Space Complexity: O(1) | ||
| def delete(value) |
Comment on lines
+133
to
+137
| # method to reverse the singly linked list | ||
| # note: the nodes should be moved and not just the values in the nodes | ||
| # Time Complexity: O(n) | ||
| # Space Complexity: O(n) | ||
| def reverse |
Comment on lines
+149
to
+153
| ## Advanced Exercises | ||
| # returns the value at the middle element in the singly linked list | ||
| # Time Complexity: O(n) | ||
| # Space Complexity: O(1) | ||
| def find_middle_value |
Comment on lines
+161
to
+163
| # Time Complexity: O(n) | ||
| # Space Complexity: O(1) | ||
| def find_nth_from_end(n) |
Comment on lines
+198
to
+200
| # Time Complexity: ? | ||
| # Space Complexity: ? | ||
| def get_first |
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.