-
Notifications
You must be signed in to change notification settings - Fork 497
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
Added Quick Select [C] #53
Conversation
@yashLadha: Please mention an issue that is completely closed by this PR. |
Also it is clear that you have made a false tick on the requirements mentioned for the PR. Please correct the errors. |
@yashLadha : This PR is not consistent with contributing guidelines. Please refer to it and make the changes. |
The closing issue link is mentioned in my commit message. |
quick_select/quick_select.c
Outdated
} else { | ||
return quick_select(ar, pivot_index + 1, right, pos); | ||
} | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this case will never be reached, it looks confusing to return 0
when we have to return one of the numbers from the array. What do you think @yashLadha?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sir it is because of a warning that all the return statements are inside the conditional blocks and there is a warning issued at this point because function will not return any value if in any hypothetical case it doesn't go into any conditional block statement, and it requires a return statement. If you wan't i can remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that there would be a warning.
quick_select/quick_select.c
Outdated
} | ||
|
||
int quick_select(int *ar, int left, int right, int pos) { | ||
int pivot_index = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assigned value to variable pivot_index
has not been used.
int ar[] = {10, 5, 1, 6, 7, 3, 2, 4, 8, 9}; | ||
printf("%d\n", quick_select(ar, 0, 9, 3)); | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End with a new line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added newline
quick_select/quick_select.c
Outdated
@@ -0,0 +1,45 @@ | |||
#include <stdio.h> | |||
#include <stdlib.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module never used.
3bbc5ce
to
b1fb210
Compare
Ammended Necessary changes. |
Looks okay. Let's wait for some more eyes. |
@@ -0,0 +1,45 @@ | |||
#include <stdio.h> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add comments about the parameters making it easy for a reader to know about the work of the parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the comments. Can review them.
quick_select/quick_select.c
Outdated
* right : right index of the subarray | ||
* pos : position to find the element using quick sort | ||
* pivot_index : pivot index | ||
* return : int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better be specific about what int
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the return type of function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it looks strange. We have a list of parameters and out of nowhere we see the return type. What I see is that the return type is already indicated very clearly in C
(int quick_select(...) {}
). It would be better to add what it returns instead of return type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logical meaning or the variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logical meaning.
Closes #10
@Monal5031 : Do things look good? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, everything look's fine.
Fixes #10
By submitting this pull request I confirm I've read and complied with the below requirements.
Added {Algorithm name} [{Language}]
, notUpdate README.md
orAdded new code
.