Skip to content

Leaves - Yitgop#42

Open
rinostar wants to merge 4 commits into
Ada-C12:masterfrom
rinostar:master
Open

Leaves - Yitgop#42
rinostar wants to merge 4 commits into
Ada-C12:masterfrom
rinostar:master

Conversation

@rinostar

Copy link
Copy Markdown

No description provided.

@CheezItMan CheezItMan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not bad, you hit the main learning goals here. Well done. Check out my comments and let me know if you have questions.

Comment thread lib/using_restricted_array.rb Outdated
while n < length
if value_to_find == array[n]
return true
found += 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.

This line can't be reached

Comment thread lib/using_restricted_array.rb Outdated
n += 1
end

if found == 0

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 can simply return false if this line is encountered, there's no need for an if statement.

Comment thread lib/using_restricted_array.rb Outdated
mid = (low + high)/2
if array[mid] == value_to_find
return true
found += 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.

Since you are returning this line will never execute.

Comment thread lib/using_restricted_array.rb Outdated
end
end

if found == 0

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 has the same problem as linear search

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