Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Not your best work. A few comments.
- It seems your new IDE is messing up your indentation and causing you to check in XML files to git. Something to work on.
- Look for ways to reuse methods, some of them can pay off here.
You hit most of the learning goals, but definitely had some problems. Take a look at my comments and let me know what questions you have.
| # Space Complexity | ||
| def delete(value) | ||
| raise NotImplementedError | ||
| visit_array = [] |
There was a problem hiding this comment.
You have some weird indentation here.
| @@ -0,0 +1,9 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
What is all this? Maybe put .idea folder in .gitignore.
| # Time Complexity: | ||
| # Space Complexity | ||
| # Time Complexity: O(1) (constant), because the length of the list doesn't matter | ||
| # Space Complexity: O(n), where n is the length of the list |
There was a problem hiding this comment.
But the method itself doesn't add more space to the list, it only adds 1 element.
| def search(value) | ||
| raise NotImplementedError | ||
| node = @head | ||
| return false if !node.next |
There was a problem hiding this comment.
What if @Head is nil?
What if the value is in the head and the list only has 1 element?
| raise NotImplementedError | ||
| current = @head | ||
|
|
||
| return 0 if current.nil? |
| current = current.next | ||
| count += 1 | ||
| end | ||
| current.data |
There was a problem hiding this comment.
What if the index is past the end of the list?
| previous_node = nil | ||
|
|
||
|
|
||
| while current_node |
| else | ||
| before.next = current.next | ||
| end | ||
| return "deleted" |
| # method to delete the first node found with specified value | ||
| # Time Complexity: O(n) | ||
| # Space Complexity: O(1) | ||
| def delete(value) |
| # Space Complexity: O(1) | ||
| def find_nth_from_end(n) | ||
| raise NotImplementedError | ||
| selected_index = length - n - 1 |
There was a problem hiding this comment.
Could you have also used the method to get an element at an index?
No description provided.