Skip to content

Conversation

@realDuYuanChao
Copy link
Member

@realDuYuanChao realDuYuanChao commented Oct 8, 2019

Find max and min value using Divide and Conquer algorithms

:param nums: contains elements
:param left: index of first element
:param right: index of last element
:return: min in nums
Copy link
Member

Choose a reason for hiding this comment

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

:return: says min but should say max.

Also, add doctests as discussed in CONTRIBUTING.md

>>> nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
>>> find_max(nums, 0, len(nums) - 1) = max(nums)
True

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated, Thanks for your review! @cclauss

Copy link
Member

Choose a reason for hiding this comment

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

Both files need doctests like the one above.

Copy link
Member Author

@realDuYuanChao realDuYuanChao Oct 8, 2019

Choose a reason for hiding this comment

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

Please review again! @cclauss

Copy link
Member Author

@realDuYuanChao realDuYuanChao Oct 8, 2019

Choose a reason for hiding this comment

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

:return: says min but should say max.

Also, add doctests as discussed in CONTRIBUTING.md

>>> nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
>>> find_max(nums, 0, len(nums) - 1) = max(nums)
True

I updated as you say, correct?

:param right: index of last element
:return: max in nums

>>find_max([1, 3, 5, 7, 9, 2, 4, 6, 8, 10], 0, 9) == 10
Copy link
Member

Choose a reason for hiding this comment

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

greater than >, greater than >, greater than >, space

If not, it is not recognizing as a test.

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean like this nums = [9, 7, 5, 3, 2, 1] ?

Copy link
Member

Choose a reason for hiding this comment

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

Nope. I mean:

  >>> find_max(...
# not...
  >>find_max(...

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I corrected follow as you say.

Copy link
Member Author

Choose a reason for hiding this comment

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

Please review again! @cclauss

@realDuYuanChao
Copy link
Member Author

Please review again @cclauss

:return: max in nums
"""

"""
Copy link
Member

Choose a reason for hiding this comment

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

Remove lines 9 and 11.

:param right: index of last element
:return: min in nums
"""

Copy link
Member

Choose a reason for hiding this comment

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

Remove lines 9 and 11.

Copy link
Member

Choose a reason for hiding this comment

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

Is this change done?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes!Done

@realDuYuanChao
Copy link
Member Author

Please review again! @cclauss

@realDuYuanChao
Copy link
Member Author

@cclauss Did you forget review?😹

@cclauss cclauss merged commit 83c104e into TheAlgorithms:master Oct 18, 2019
@realDuYuanChao realDuYuanChao deleted the patch-1 branch November 3, 2019 13:22
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
Thanks for your persistence!
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