Skip to content

Ports - Ari#28

Open
aribray wants to merge 2 commits intoAda-C11:masterfrom
aribray:master
Open

Ports - Ari#28
aribray wants to merge 2 commits intoAda-C11:masterfrom
aribray:master

Conversation

@aribray
Copy link
Copy Markdown

@aribray aribray commented Aug 28, 2019

No description provided.

Copy link
Copy Markdown

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Not your best work. A few comments.

  1. It seems your new IDE is messing up your indentation and causing you to check in XML files to git. Something to work on.
  2. 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.

Comment thread lib/linked_list.rb
# Space Complexity
def delete(value)
raise NotImplementedError
visit_array = []
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You have some weird indentation here.

Comment thread lib/.idea/lib.iml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is all this? Maybe put .idea folder in .gitignore.

Comment thread lib/linked_list.rb
# 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

But the method itself doesn't add more space to the list, it only adds 1 element.

Comment thread lib/linked_list.rb
def search(value)
raise NotImplementedError
node = @head
return false if !node.next
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What if @Head is nil?
What if the value is in the head and the list only has 1 element?

Comment thread lib/linked_list.rb
raise NotImplementedError
current = @head

return 0 if current.nil?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you need this return?

Comment thread lib/linked_list.rb
current = current.next
count += 1
end
current.data
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What if the index is past the end of the list?

Comment thread lib/linked_list.rb
previous_node = nil


while current_node
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
else
before.next = current.next
end
return "deleted"
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
# method to delete the first node found with specified value
# Time Complexity: O(n)
# Space Complexity: O(1)
def delete(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.

This isn't working.

Comment thread lib/linked_list.rb
# Space Complexity: O(1)
def find_nth_from_end(n)
raise NotImplementedError
selected_index = length - n - 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could you have also used the method to get an element at an index?

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