Open
Conversation
CheezItMan
reviewed
Feb 23, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work, you hit all the learning goals here. Well done. Take a look at my comments and let me know if you have questions. The methods you have written all work and you've demonstrated an understanding of how to implement a Linked List. Only a few such as find middle and insert ascending were not implemented. Well done.
| raise NotImplementedError | ||
| # method to return the max value in the linked list | ||
| # returns the data value and not the node | ||
| def find_max |
| raise NotImplementedError | ||
| # method to find if the linked list contains a node with specified value | ||
| # returns true if found, false otherwise | ||
| def search(value) |
| end | ||
| # 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 | ||
| def add_first(value) |
| raise NotImplementedError | ||
| # method to return the min value in the linked list | ||
| # returns the data value and not the node | ||
| def find_min |
| def visit | ||
| raise NotImplementedError | ||
| # method that returns the length of the singly linked list | ||
| def length |
Comment on lines
+141
to
+143
| def find_middle_value | ||
| raise NotImplementedError | ||
| end |
Comment on lines
+151
to
+154
| length = 0 | ||
| until current.next.nil? | ||
| length += 1 | ||
| current = current.next |
There was a problem hiding this comment.
Why not use the existing length method?
| # returns the value in the first node | ||
| # returns nil if the list is empty | ||
| def get_first | ||
| return @head ? @head.data : nil |
|
|
||
| # navigate to last node | ||
| # method that inserts a given value as a new last node in the linked list | ||
| def add_last(value) |
| current.next = @head # make the last node link to first node | ||
| # method that returns the value of the last node in the linked list | ||
| # returns nil if the linked list is empty | ||
| def get_last |
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.