-
Notifications
You must be signed in to change notification settings - Fork 302
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
add binary search in c #593
Conversation
I went through the logs of Travis CI. It says there are some extra whitespaces in my source code. So, should I fix it or is it good enough for a merge? |
Yes @varunkmr19, the fix is needed. Also, it would be great if you go through https://github.com/NITSkmOS/Algorithms/blob/master/CONTRIBUTING.md#write-good-commit-messages and do the necessary changes. Also, can you add entry in README.md? |
@varunkmr19 There are few things that need to be sorted for this PR to get merged. a) At line 5, we cannot obtain the size of an array after passing it inside a function because only the first address of the array is passed inside the function. b) Also, update the README file and remove the extra spacing. Everything else looks good. |
Don't know why It's not passing all the checks. Even after I fixed the code and removed the extra spacing as well. |
@@ -58,6 +58,7 @@ This repository contains examples of various algorithms written on different pro | |||
4. Commit your changes: `git commit -am 'Add some feature'`. | |||
|
|||
Go through [Commit Messages guidelines](CONTRIBUTING.md#write-good-commit-messages) | |||
|
|||
5. Push to the branch: `git push origin my-new-feature` | |||
6. Submit a pull request :smile: | |||
|
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 changes in this file is redundant. Kindly change only line that is required.
Finally, I found out what the issue was. I had installed prettier(a VScode extension) which was messing with the alignment. |
That's great. But, please squash your commits. |
@varunkmr19 can you please go through the review comments and do the changes that are requested? |
This adds Binary Search Algorithm which finds the position of a target value within a sorted array. It compares the target value to the middle element of the array. Closes http://github.com/NITSkmOS/Algorithms/issues/44
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 have added few suggestions that needs to be done and make sure to do git commit --amend
instead of git commit
. And in the commit message, add line break after 80 characters so that each line just consists 80 chars. For ref, https://github.com/NITSkmOS/Algorithms/blob/master/CONTRIBUTING.md#commit-body.
Rest looks good to me.
| Data Structure | C | CPP | Java | Python | | ||
| :--------------------------------------------------------------------- | :-------------------------------: | :---------------------------------: | :----------------------------: | :------------------------------: | | ||
| [Queue](<https://en.wikipedia.org/wiki/Queue_(abstract_data_type)>) | | [:octocat:](queue/Cpp) | | | | ||
| [Stack](<https://en.wikipedia.org/wiki/Stack_(abstract_data_type)>) | [:octocat:](stack/C) | | [:octocat:](stack/Java) | [:octocat:](stack/Python) | | ||
| [Linear Linked List](https://en.wikipedia.org/wiki/Linked_list) | [:octocat:](linked_list/C) | [:octocat:](linked_list/Cpp) | [:octocat:](linked_list/Java) | [:octocat:](linked_list/Python) | | ||
| [AVL Tree](https://en.wikipedia.org/wiki/AVL_tree) | [:octocat:](avl_tree/C) | [:octocat:](avl_tree/Cpp) | [:octocat:](avl_tree/Java) | [:octocat:](avl_tree/Python) | | ||
| [Binary Search Tree](https://en.wikipedia.org/wiki/Binary_search_tree) | | [:octocat:](binary_search_tree/Cpp) | | | | ||
| [Fenwick Tree](https://en.wikipedia.org/wiki/Fenwick_tree) | | [:octocat:](fenwick_tree/Cpp) | [:octocat:](fenwick_tree/java) | [:octocat:](fenwick_tree/Python) | | ||
| [Doubly Linked List](https://en.wikipedia.org/wiki/Doubly_linked_list) | [:octocat:](doubly_linked_list/c) | | | | |
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, do not do unnecessary changes
| Data Structure | C | CPP | Java | Python | | |
| :--------------------------------------------------------------------- | :-------------------------------: | :---------------------------------: | :----------------------------: | :------------------------------: | | |
| [Queue](<https://en.wikipedia.org/wiki/Queue_(abstract_data_type)>) | | [:octocat:](queue/Cpp) | | | | |
| [Stack](<https://en.wikipedia.org/wiki/Stack_(abstract_data_type)>) | [:octocat:](stack/C) | | [:octocat:](stack/Java) | [:octocat:](stack/Python) | | |
| [Linear Linked List](https://en.wikipedia.org/wiki/Linked_list) | [:octocat:](linked_list/C) | [:octocat:](linked_list/Cpp) | [:octocat:](linked_list/Java) | [:octocat:](linked_list/Python) | | |
| [AVL Tree](https://en.wikipedia.org/wiki/AVL_tree) | [:octocat:](avl_tree/C) | [:octocat:](avl_tree/Cpp) | [:octocat:](avl_tree/Java) | [:octocat:](avl_tree/Python) | | |
| [Binary Search Tree](https://en.wikipedia.org/wiki/Binary_search_tree) | | [:octocat:](binary_search_tree/Cpp) | | | | |
| [Fenwick Tree](https://en.wikipedia.org/wiki/Fenwick_tree) | | [:octocat:](fenwick_tree/Cpp) | [:octocat:](fenwick_tree/java) | [:octocat:](fenwick_tree/Python) | | |
| [Doubly Linked List](https://en.wikipedia.org/wiki/Doubly_linked_list) | [:octocat:](doubly_linked_list/c) | | | | | |
| Data Structure | C | CPP | Java | Python | | |
|:----------------------------------------------------------------------------------------------- |:-------------------------------------:|:-------------------------------------:|:-------------------------------------:|:-------------------------------------:| | |
| [Queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) | | [:octocat:](queue/Cpp) | | | | |
| [Stack](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)) | [:octocat:](stack/C ) | | [:octocat:](stack/Java) | [:octocat:](stack/Python) | | |
| [Linear Linked List](https://en.wikipedia.org/wiki/Linked_list) | [:octocat:](linked_list/C) | [:octocat:](linked_list/Cpp) | [:octocat:](linked_list/Java) | [:octocat:](linked_list/Python) | | |
| [AVL Tree](https://en.wikipedia.org/wiki/AVL_tree) | [:octocat:](avl_tree/C) | [:octocat:](avl_tree/Cpp) | [:octocat:](avl_tree/Java) | [:octocat:](avl_tree/Python) | | |
| [Binary Search Tree](https://en.wikipedia.org/wiki/Binary_search_tree) | | [:octocat:](binary_search_tree/Cpp) | | | | |
| [Fenwick Tree](https://en.wikipedia.org/wiki/Fenwick_tree) | | [:octocat:](fenwick_tree/Cpp) | [:octocat:](fenwick_tree/java) | [:octocat:](fenwick_tree/Python) | | |
| [Doubly Linked List](https://en.wikipedia.org/wiki/Doubly_linked_list) | [:octocat:](doubly_linked_list/c) | | | | |
| Language | Steps | | ||
| ---------- | ------------------------------------------------------------------ | | ||
| JavaScript | <pre>node [filename.js]</pre> | | ||
| Python | <pre>python [filename.py]</pre> | | ||
| C | <pre>gcc [filename.c]<br>./a.out # unix<br>a.exe # windows</pre> | | ||
| CPP | <pre>g++ [filename.cpp]<br>./a.out # unix<br>a.exe # windows</pre> | | ||
| Java | <pre>javac [filename.java]<br>java [filename]</pre> | |
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.
| Language | Steps | | |
| ---------- | ------------------------------------------------------------------ | | |
| JavaScript | <pre>node [filename.js]</pre> | | |
| Python | <pre>python [filename.py]</pre> | | |
| C | <pre>gcc [filename.c]<br>./a.out # unix<br>a.exe # windows</pre> | | |
| CPP | <pre>g++ [filename.cpp]<br>./a.out # unix<br>a.exe # windows</pre> | | |
| Java | <pre>javac [filename.java]<br>java [filename]</pre> | | |
| Language | Steps | | |
| --------------- | ---------------------------------------------------------------------- | | |
| JavaScript | <pre>node [filename.js]</pre> | | |
| Python | <pre>python [filename.py]</pre> | | |
| C | <pre>gcc [filename.c]<br>./a.out # unix<br>a.exe # windows</pre> | | |
| CPP | <pre>g++ [filename.cpp]<br>./a.out # unix<br>a.exe # windows</pre> | | |
| Java | <pre>javac [filename.java]<br>java [filename]</pre> | |
| [Insertion Sort](https://en.wikipedia.org/wiki/Insertion_sort) | [:octocat:](insertion_sort/C) | [:octocat:](insertion_sort/Cpp) | | [:octocat:](insertion_sort/Python) | | ||
| [Counting Sort](https://en.wikipedia.org/wiki/Counting_sort) | [:octocat:](counting_sort/C) | [:octocat:](counting_sort/Cpp) | | [:octocat:](counting_sort/Python) | | ||
| [Radix Sort](https://en.wikipedia.org/wiki/Radix_sort) | | [:octocat:](radix_sort/Cpp) | | [:octocat:](radix_sort/Python) | | ||
| [Binary Search](https://en.wikipedia.org/wiki/Binary_search_algorithm) | [:octocat:](binary_search/C) | [:octocat:](binary_search/Cpp) | [:octocat:](binary_search/C) | [:octocat:](binary_search/Python) | |
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 have listed you file at 2 places in this line, one in C
column and other in Java
column. I hope you understand what you are doing here
| Algorithm | C | CPP | Java | Python | | ||
| :--------------------------------------------------------------------------------- | :---------------------------: | :-----------------------------: | :-----------------------------: | :-----------------------------------: | | ||
| [Euclidean GCD](https://en.wikipedia.org/wiki/Euclidean_algorithm) | [:octocat:](euclidean_gcd/C) | | [:octocat:](euclidean_gcd/Java) | [:octocat:](euclidean_gcd/Python) | | ||
| [Merge Sort](https://en.wikipedia.org/wiki/Merge_sort) | [:octocat:](merge_sort/C) | [:octocat:](merge_sort/Cpp) | [:octocat:](merge_sort/Java) | [:octocat:](merge_sort/Python) | | ||
| [QuickSort](https://en.wikipedia.org/wiki/Quicksort) | [:octocat:](quicksort/C) | | [:octocat:](quicksort/Java) | [:octocat:](quicksort/Python) | | ||
| [Insertion Sort](https://en.wikipedia.org/wiki/Insertion_sort) | [:octocat:](insertion_sort/C) | [:octocat:](insertion_sort/Cpp) | | [:octocat:](insertion_sort/Python) | | ||
| [Counting Sort](https://en.wikipedia.org/wiki/Counting_sort) | [:octocat:](counting_sort/C) | [:octocat:](counting_sort/Cpp) | | [:octocat:](counting_sort/Python) | | ||
| [Radix Sort](https://en.wikipedia.org/wiki/Radix_sort) | | [:octocat:](radix_sort/Cpp) | | [:octocat:](radix_sort/Python) | | ||
| [Binary Search](https://en.wikipedia.org/wiki/Binary_search_algorithm) | [:octocat:](binary_search/C) | [:octocat:](binary_search/Cpp) | [:octocat:](binary_search/C) | [:octocat:](binary_search/Python) | | ||
| [Bubble Sort](https://en.wikipedia.org/wiki/Bubble_sort) | [:octocat:](bubble_sort/C) | [:octocat:](bubble_sort/Cpp) | [:octocat:](bubble_sort/Java) | [:octocat:](bubble_sort/Python) | | ||
| [Shell Sort](https://en.wikipedia.org/wiki/Shellsort) | [:octocat:](shell_sort/C) | | | [:octocat:](shell_sort/Python) | | ||
| [Heap Sort](https://en.wikipedia.org/wiki/Heapsort) | | | | [:octocat:](heap_sort/python) | | ||
| [Maximum Subarray Problem](https://en.wikipedia.org/wiki/Maximum_subarray_problem) | | | | [:octocat:](/maximum_subarray/Python) | | ||
| [Knapsack Problem](https://en.wikipedia.org/wiki/Knapsack_problem) | | | | [:octocat:](knapsack_problem/Python) | | ||
| [Selecton Sort](https://en.wikipedia.org/wiki/Selection_sort) | [:octocat:](selection_sort/C) | [:octocat:](selection_sort/Cpp) | | | |
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.
| Algorithm | C | CPP | Java | Python | | |
| :--------------------------------------------------------------------------------- | :---------------------------: | :-----------------------------: | :-----------------------------: | :-----------------------------------: | | |
| [Euclidean GCD](https://en.wikipedia.org/wiki/Euclidean_algorithm) | [:octocat:](euclidean_gcd/C) | | [:octocat:](euclidean_gcd/Java) | [:octocat:](euclidean_gcd/Python) | | |
| [Merge Sort](https://en.wikipedia.org/wiki/Merge_sort) | [:octocat:](merge_sort/C) | [:octocat:](merge_sort/Cpp) | [:octocat:](merge_sort/Java) | [:octocat:](merge_sort/Python) | | |
| [QuickSort](https://en.wikipedia.org/wiki/Quicksort) | [:octocat:](quicksort/C) | | [:octocat:](quicksort/Java) | [:octocat:](quicksort/Python) | | |
| [Insertion Sort](https://en.wikipedia.org/wiki/Insertion_sort) | [:octocat:](insertion_sort/C) | [:octocat:](insertion_sort/Cpp) | | [:octocat:](insertion_sort/Python) | | |
| [Counting Sort](https://en.wikipedia.org/wiki/Counting_sort) | [:octocat:](counting_sort/C) | [:octocat:](counting_sort/Cpp) | | [:octocat:](counting_sort/Python) | | |
| [Radix Sort](https://en.wikipedia.org/wiki/Radix_sort) | | [:octocat:](radix_sort/Cpp) | | [:octocat:](radix_sort/Python) | | |
| [Binary Search](https://en.wikipedia.org/wiki/Binary_search_algorithm) | [:octocat:](binary_search/C) | [:octocat:](binary_search/Cpp) | [:octocat:](binary_search/C) | [:octocat:](binary_search/Python) | | |
| [Bubble Sort](https://en.wikipedia.org/wiki/Bubble_sort) | [:octocat:](bubble_sort/C) | [:octocat:](bubble_sort/Cpp) | [:octocat:](bubble_sort/Java) | [:octocat:](bubble_sort/Python) | | |
| [Shell Sort](https://en.wikipedia.org/wiki/Shellsort) | [:octocat:](shell_sort/C) | | | [:octocat:](shell_sort/Python) | | |
| [Heap Sort](https://en.wikipedia.org/wiki/Heapsort) | | | | [:octocat:](heap_sort/python) | | |
| [Maximum Subarray Problem](https://en.wikipedia.org/wiki/Maximum_subarray_problem) | | | | [:octocat:](/maximum_subarray/Python) | | |
| [Knapsack Problem](https://en.wikipedia.org/wiki/Knapsack_problem) | | | | [:octocat:](knapsack_problem/Python) | | |
| [Selecton Sort](https://en.wikipedia.org/wiki/Selection_sort) | [:octocat:](selection_sort/C) | [:octocat:](selection_sort/Cpp) | | | | |
| Algorithm | C | CPP | Java | Python | | |
|:----------------------------------------------------------------------------------------------- |:-------------------------------------:|:-------------------------------------:|:-------------------------------------:|:-------------------------------------:| | |
| [Euclidean GCD](https://en.wikipedia.org/wiki/Euclidean_algorithm) | [:octocat:](euclidean_gcd/C) | | [:octocat:](euclidean_gcd/Java) | [:octocat:](euclidean_gcd/Python) | | |
| [Merge Sort](https://en.wikipedia.org/wiki/Merge_sort) | [:octocat:](merge_sort/C) | [:octocat:](merge_sort/Cpp) | [:octocat:](merge_sort/Java) | [:octocat:](merge_sort/Python) | | |
| [QuickSort](https://en.wikipedia.org/wiki/Quicksort) | [:octocat:](quicksort/C) | | [:octocat:](quicksort/Java) | [:octocat:](quicksort/Python) | | |
| [Insertion Sort](https://en.wikipedia.org/wiki/Insertion_sort) | [:octocat:](insertion_sort/C) | [:octocat:](insertion_sort/Cpp) | | [:octocat:](insertion_sort/Python) | | |
| [Counting Sort](https://en.wikipedia.org/wiki/Counting_sort) | [:octocat:](counting_sort/C) | [:octocat:](counting_sort/Cpp) | | [:octocat:](counting_sort/Python) | | |
| [Radix Sort](https://en.wikipedia.org/wiki/Radix_sort) | | [:octocat:](radix_sort/Cpp) | | [:octocat:](radix_sort/Python) | | |
| [Binary Search](https://en.wikipedia.org/wiki/Binary_search_algorithm) | [:octocat:](binary_search/C) | [:octocat:](binary_search/Cpp) | | [:octocat:](binary_search/Python) | | |
| [Bubble Sort](https://en.wikipedia.org/wiki/Bubble_sort) | [:octocat:](bubble_sort/C) | [:octocat:](bubble_sort/Cpp) | [:octocat:](bubble_sort/Java) | [:octocat:](bubble_sort/Python) | | |
| [Shell Sort](https://en.wikipedia.org/wiki/Shellsort) | [:octocat:](shell_sort/C) | | | [:octocat:](shell_sort/Python) | | |
| [Heap Sort](https://en.wikipedia.org/wiki/Heapsort) | | | | [:octocat:](heap_sort/python) | | |
| [Maximum Subarray Problem](https://en.wikipedia.org/wiki/Maximum_subarray_problem) | | | | [:octocat:](/maximum_subarray/Python) | | |
| [Knapsack Problem](https://en.wikipedia.org/wiki/Knapsack_problem) | | | | [:octocat:](knapsack_problem/Python) | | |
| [Selecton Sort](https://en.wikipedia.org/wiki/Selection_sort) | [:octocat:](selection_sort/C) | [:octocat:](selection_sort/Cpp) | | | |
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Fixes #44
By submitting this pull request I confirm I've read and complied with the
below declarations.
{Tag}: Add {Algorithm/DS name} [{Language}]
, notUpdate README.md
orAdded new code
.After you submit your pull request, DO NOT click the 'Update Branch' button.