Algorithms icon indicating copy to clipboard operation
Algorithms copied to clipboard

Using inherited swap method

Open mavharsha opened this issue 7 years ago • 9 comments

Using inherited swap method from abstract class SortingAlgorithm.

mavharsha avatar Jul 07 '17 06:07 mavharsha

Hi! @mavharsha

Using inherited swap method from abstract class SortingAlgorithm.

I can not see in SortingAlgorithm. Are you taking about this? Also did not get why Travis-ci fail? Can you help what test case is failing?

jitendra3109 avatar Jul 11 '17 18:07 jitendra3109

Hello @jsroyal ,

  1. QuickSort extends SortingAlgorithm. https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/sortingalgorithm/SortingAlgorithm.java#L27 which has swap function.

  2. The build failed because it is unable to sort (while loop in the partition function goes in an infinite loop) the give inputs. (When the inputs have duplicates) I modified an existing test rather than creating a new test.

Hope this clarifies.

mavharsha avatar Jul 11 '17 19:07 mavharsha

  1. The build failed because it is unable to sort (while loop in the partition function goes in an infinite loop) the give inputs. (When the inputs have duplicates)

Input code twice with modified-> image

image

image

So I do not think this couse for travic build failed.

2.QuickSort extends SortingAlgorithm. https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/sortingalgorithm/SortingAlgorithm.java#L27 which has swap function.

Sorry! I just missed. BTW thanks for that -> PR.

jitendra3109 avatar Jul 12 '17 03:07 jitendra3109

Hey @jsroyal

Can you please run the QuickSortTest with modified input values against the code in master.

The code implementation in your screenshot isn't similar to QuickSort implementation in master. Thanks.

quick_sort

mavharsha avatar Jul 12 '17 04:07 mavharsha

Oh! Sorry. Yeah, It is. Bug in code. And I thought it was my code but it seems not even the author name is mine. So yeah I will have to look it. Thanks @mavharsha

jitendra3109 avatar Jul 12 '17 07:07 jitendra3109

No worries! :)

mavharsha avatar Jul 12 '17 07:07 mavharsha

Hey @mavharsha seems that you've found a bug! If the array contains duplicated values our quick sort implementation is not going to work due to an infinite loop! Now you've discovered the bug, could you fix it? It has to be a minor issue 😃

pedrovgs avatar Aug 05 '17 08:08 pedrovgs

Sure @pedrovgs! (:

mavharsha avatar Aug 05 '17 08:08 mavharsha

Thanks @mavharsha 😄

pedrovgs avatar Aug 05 '17 08:08 pedrovgs