-
Notifications
You must be signed in to change notification settings - Fork 496
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 Depth first traversal [C] #253
Conversation
A program in C++ to perform a recursive binary search.
C++ implementation of recursive binary search.
Adding this program to the recursive_binary_search directory.
Updated the program for recursive binary search [C++].
Updated the link for recursive binary search because it was added to a new directory.
Corrected the indentation according to the standards.
Added recursive implementation to binary_search.c [ C ]
Added it to binary_search.c
Removed binary_search link for C++ because the file was merged with binary_search.c [ C ]
Updated the name of binarySearch function to recursive_binary_search
Corrected indentation in recursive_binary_search.c
Updated with proper brackets
Added required white spaces.
Whitespace around binary operator
Created program file for depth-first traversal in C language.
Indentation inaccuracy resolved.
Updated README.md for depth_first_traversal.c
if (ar[mid] == ele) { | ||
return mid; | ||
} | ||
|
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.
Please rebase correctly. These changes are not a part of this PR.
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.
@aviaryan Ok, how do I do that? Can you help?
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.
Just delete these (extra) lines from your branch. This has been already merged.
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.
@aviaryan How do I delete the extra lines?
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.
Just undo what change is show in binary_search.c file https://github.com/iiitv/algos/pull/253/files#diff-2b5f8e5dede4db6a4fea7b2769c4f983R8
|
||
for ( int j=0; j<size; j++) { | ||
if(ar[start][j] == 1 && visited[j]==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.
Avoid giving extra empty lines. Only give empty lines where necessary. (e.g. Adding a blank line helps to symbolize different steps of the code)
@size - size of the array | ||
*/ | ||
|
||
void depth_first_search(int ar[5][5], int *visited, int start, int size) { |
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.
If this is a search, then what are you searching for?
{0, 0, 0, 0, 0} | ||
}; | ||
|
||
int visited[5] = {0, 0, 0, 0, 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.
you can use memset for this purpose and instead of directly using 5
you can use a separate variable for it.
* @r - right index of array. | ||
* @ele - element to be searched. | ||
*/ | ||
int recursive_binary_search(const int *ar, int l, int r, int ele) { |
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.
Remove these changes.
@HarshKhatore Please update this PR, if you are having trouble you can ask at gitter. This PR will be closed after two days so please do it in time. |
@aviaryan Sir please close this one due to inactivity. |
Fixes #250
By submitting this pull request I confirm I've read and complied with the below declarations.
Added {Algorithm/DS name} [{Language}]
, notUpdate README.md
orAdded new code
.