Skip to content

Conversation

@lukasb1b
Copy link
Contributor

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

This change schould make FindMin more efficient.

@vil02
Copy link
Member

vil02 commented Sep 21, 2023

I am skeptic about this change. I am not even sure if it really improves the performance. For example: in your code the i is a 32-bit integer - is it really the best way to iterate on a 64-bit system?

The generated code is indeed different: old vs. new.

This file has more important problems.

@siriak what do you think?

@siriak
Copy link
Member

siriak commented Sep 24, 2023

I'd say that it's more efficient from an algorithmic perspective because it uses 1 iteration less. Not sure if this translates into real-world performance, though. Nevertheless, I like the change because we are concerned with algorithms and this is a good example of how to eliminate a redundant iteration (it's redundant because array[i] < min is always true on the first iteration)

@siriak siriak enabled auto-merge (squash) September 24, 2023 06:24
@siriak siriak merged commit c1476d7 into TheAlgorithms:master Sep 24, 2023
@lukasb1b lukasb1b deleted the FindMin-more-efficient branch September 24, 2023 06:45
@lukasb1b lukasb1b mentioned this pull request Sep 24, 2023
4 tasks
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.

3 participants