Skip to content

Branches - Amal #31

Open
ashassan wants to merge 1 commit into
Ada-C12:masterfrom
ashassan:master
Open

Branches - Amal #31
ashassan wants to merge 1 commit into
Ada-C12:masterfrom
ashassan:master

Conversation

@ashassan
Copy link
Copy Markdown

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.

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.

Comment thread lib/linked_list.rb
raise NotImplementedError
# method to return the max value in the linked list
# returns the data value and not the node
def find_max
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
raise NotImplementedError
# method to find if the linked list contains a node with specified value
# returns true if found, false otherwise
def search(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.

👍

Comment thread lib/linked_list.rb
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)
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
raise NotImplementedError
# method to return the min value in the linked list
# returns the data value and not the node
def find_min
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
def visit
raise NotImplementedError
# method that returns the length of the singly linked list
def length
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
Comment on lines +141 to +143
def find_middle_value
raise NotImplementedError
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just noting this isn't implemented

Comment thread lib/linked_list.rb
Comment on lines +151 to +154
length = 0
until current.next.nil?
length += 1
current = current.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.

Why not use the existing length method?

Comment thread lib/linked_list.rb
# returns the value in the first node
# returns nil if the list is empty
def get_first
return @head ? @head.data : 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.

Nice use of a ternary

Comment thread lib/linked_list.rb

# navigate to last node
# method that inserts a given value as a new last node in the linked list
def add_last(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.

👍

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

Choose a reason for hiding this comment

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

👍

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