Skip to content

Add Sorting algorithm QuickSortMedianOfThree #294

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

Conversation

italo-batista
Copy link

No description provided.

@italo-batista italo-batista mentioned this pull request Oct 31, 2017
Copy link

@christianbender christianbender left a comment

Choose a reason for hiding this comment

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

Good Work! I have some requests

private void medianOfThree(int[] array, int leftIndex, int rightIndex){

int shortter = leftIndex;
int mid = leftIndex + (rightIndex - leftIndex) / 2;

Choose a reason for hiding this comment

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

Write instead int mid = (rightIndex + leftIndex) / 2;. Because simpler!

}

private void changePivot(int[] array, int leftIndex, int rightIndex) {
int pivotIndex = leftIndex + (rightIndex - leftIndex) / 2;

Choose a reason for hiding this comment

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

Write instead int pivotIndex = (rightIndex + leftIndex) / 2;. Because simpler.

}

private void swap(int[] array, int i, int j) {
if(array == null)

Choose a reason for hiding this comment

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

  • Use curly braces.
  • This exception handling you can write to the methods above, too.

int leftIndex = 0;
int rightIdex = array.length - 1;

QuickSortMedianOfThree quick = new QuickSortMedianOfThree();

Choose a reason for hiding this comment

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

If you write the methods above as static you can use the methods right on.

}

}

Choose a reason for hiding this comment

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

Put in some comments in your code.

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