Skip to content

Branches-Steph#48

Open
Steph0088 wants to merge 3 commits into
Ada-C12:masterfrom
Steph0088:master
Open

Branches-Steph#48
Steph0088 wants to merge 3 commits into
Ada-C12:masterfrom
Steph0088:master

Conversation

@Steph0088

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.

I'm glad you got this in. A few minor mistakes in a few of the methods here. Take a look at my suggestions and let me know if you have questions.

# Space complexity: O(1)
def binary_search(array, length, value_to_find)
raise NotImplementedError
bigger = array.length - 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.

In restricted Array, length is not a method. It's a parameter passed in.

Suggested change
bigger = array.length - 1
bigger = length - 1

bigger = array.length - 1
smaller = 0
while bigger >= smaller
middle = (high + low) / 2

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 need to define high and low here before the loop starts. Maybe use smaller and bigger.

Suggested change
middle = (high + low) / 2
middle = (bigger + smaller) / 2

while i < length
if array[i] < smallest
smallest = array[i]
i += 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.

You don't want to do this twice in the while loop.

Suggested change
i += 1

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