Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Margaret #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Margaret #5

wants to merge 1 commit into from

Conversation

msfinnan
Copy link

No description provided.

Copy link

@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.

Well done, you hit the major learning goals. Check out my comments below and let me know if you have questions.

@@ -6,158 +6,294 @@ class Node

def initialize(value, next_node = nil)
@data = value
@next = next_node
@next = nil

Choose a reason for hiding this comment

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

Not sure why you made this change?

def add_first(value)
new_node = Node.new(value)

if @head != nil #if list isn't empty

Choose a reason for hiding this comment

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

Even if @head is nil, wouldn't the line below still work?

def search(value)
raise NotImplementedError
current = @head
while @next != nil

Choose a reason for hiding this comment

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

Don't you mean while current != nil, and you should be doing current = current.next

# note: the nodes should be moved and not just the values in the nodes
# Time Complexity: 0(n) where n is length of linked list bc we are checking each node
# Space Complexity: constant, extra space needed for variables does not grow as the size of the LL grows
def reverse

Choose a reason for hiding this comment

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

👍

# Time Complexity:
# Space Complexity
def find_nth_from_end(n)
#copied from solution branch so tests for reverse could run

Choose a reason for hiding this comment

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

Noted

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