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

Hana #21

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

Hana #21

wants to merge 1 commit into from

Conversation

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

There are a lot of good things here, but some unfinished work as well and some bugs. Take a look at my comments and let me know if you have any questions.

Remember I have office hours and can meet by appointment.

@@ -14,79 +15,213 @@ def initialize(value, next_node = nil)
class LinkedList
def initialize
@head = nil # keep the head private. Not accessible outside this class
@tail = nil

Choose a reason for hiding this comment

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

Nice!

# end
# @tail = current

print @head.data

Choose a reason for hiding this comment

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

This doesn't need to be in the submission.

# Space Complexity
def add_last(value)
new_node = Node.new(value)
@tail = new_node

Choose a reason for hiding this comment

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

You should do @tail.next = new_node before this. Then except for checking if the list was empty before, you would be finished. No loop required.

current = @head

if current
index.times do

Choose a reason for hiding this comment

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

What if index is larger than the size of the list?

raise NotImplementedError
if @head
current = @head
max = 0

Choose a reason for hiding this comment

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

What if the list is filled with negative numbers? What if it's not a list of integers?

# Time Complexity:
# Space Complexity
def length
raise NotImplementedError
# CHRIS - this isn't working! I'm pretty sure this is because it's not updating tail, bu

Choose a reason for hiding this comment

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

This is because your add_last method isn't updating @tail properly.

def get_at_index(index)
raise NotImplementedError
def search(value)
current = @head

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?


count.times do

Choose a reason for hiding this comment

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

This works, but it's an O(n2) algorithm. Is there a better way?

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