MATLAB-Octave icon indicating copy to clipboard operation
MATLAB-Octave copied to clipboard

Add more algorithms!

Open cozek opened this issue 5 years ago • 13 comments

EDIT 6/10/20: If you are making a PR for hacktoberfest, please say so in your PR description so that I can add the hacktoberfest-accepted label.

This repo needs more algorithms. If you see any missing algorithms, kindly contribute. Hackotberfest participants are welcome! I will list some of the algorithms that are up for grabs. However, please check if the algorithm is already in our repo before you begin working. Feel free to help me add more items to the list. If you have any questions, ask away!

Some Guidelines:

  1. Please create 1 pull request per algorithm for ease of review.
  2. Please do not plagiarise. Implementations must be your own. If you have used help from some article (say Wikipedia), give credit in your script in a comment.
  3. Give a brief explanation/links of what your script does.
  4. Give helpful comments where you deem necessary. Don't add comments where it's trivial such as x = y + z % adds two numbers or is unnecessary.
  5. Use proper variable names and filename. If you are working on prime check, please use a proper file name such as prime_check.m rather than primec.m
  6. Incase your algorithm required multiple files, create a subdirectory, for example, the kmeans algorithm requires two files, so we have a subdirectory for it. Try not to add unnecessary files.
  7. This repo is for educational purposes. Please keep that in mind when you are working on a contribution to this repo.
  8. Following this coding style guideline is recommended for all PRs.

Sorting Algorithms:

  • [x] Merge sort
  • [x] Insertion Sort
  • [ ] Radix sort
  • [x] Quick sort
  • [x] Bubble sort
  • [ ] Bucket sort

Searching Algorithms:

  • [x] Linear Search
  • [x] Binary Search
  • [ ] Quick Search
  • [ ] Jump Search

Math:

  • [x] Factorial
  • [x] Fibonacci series
  • [x] Prime factors
  • [x] Prime check
  • [ ] Softmax
  • [x] Jaccard Similarity
  • [ ] Greatest Common Divisor
  • [x] Euclidean Distance
  • [ ] Hamming Distance
  • [x] Find LCM
  • [x] Find HCF
  • [ ] Sum of arithmetic series
  • [ ] Sum of geometric series

Machine Learning: NOTE: Please try to use standard datasets for these problems that are freely available and perhaps popular, such as the iris dataset. Or datasets that are already inbuilt in Matlab/Octave.

  • [x] Linear Regression
  • [ ] Logistic Regression
  • [x] Gradient Descent
  • [ ] DBScan
  • [ ] K nearest neighbors
  • [ ] K medoid clustering
  • [ ] Fuzzy C-means
  • [ ] Single Layer Perceptron
  • [ ] RBF NN

cozek avatar Oct 10 '19 02:10 cozek

Dear @cozek , I've sent PR for adding Fibonacci series to Math. please feel free to comment or ask for any changes.

MaSi-dev avatar Oct 10 '19 21:10 MaSi-dev

I've also sent PR for adding algorithm of factorial to Math.

MaSi-dev avatar Oct 10 '19 21:10 MaSi-dev

I've also sent PR for adding algorithm of factorial to Math.

I have merged your PR. Thank you for your contribution!

cozek avatar Oct 12 '19 10:10 cozek

Thanks for your kind response. You should actually notice that you mustn't change the file name from factor.m to factorial.m, because Matlab already has a function with the same name and our factorial function will be unusable!

MaSi-dev avatar Oct 12 '19 10:10 MaSi-dev

Thanks for your kind response. You should actually notice that you mustn't change the file name from factor.m to factorial.m, because Matlab already has a function with the same name and our factorial function will be unusable!

Seems like I did an oopsie. Hahaha. No matter, the name change is just for indexing purpose. I am sure our readers will notice the problem and change the file/function names accordingly. Or perhaps, we should leave a comment in the script making our readers aware.

EDIT: i changed it to find_factorial. I think that solves the issue.

cozek avatar Oct 12 '19 10:10 cozek

@atousa1 @MaSi-dev I have added more problems to the math section, have a look! :)

cozek avatar Oct 12 '19 12:10 cozek

I made a PR for an insertion sorting algorithm.

MatteoRaso avatar Feb 02 '20 07:02 MatteoRaso

Hi, I will review it soon. Thanks!

On Sun, 2 Feb 2020 at 13:18, MatteoRaso [email protected] wrote:

I made a PR for an insertion sorting algorithm.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TheAlgorithms/MATLAB-Octave/issues/9?email_source=notifications&email_token=ACXBUNMJPJM2CTOUIMJ2S3LRAZ3GHA5CNFSM4I7HDDMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKRQEMY#issuecomment-581108275, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXBUNPLAAMW4GTWPNV4CL3RAZ3GHANCNFSM4I7HDDMA .

cozek avatar Feb 03 '20 15:02 cozek

I made a PR for two image processing algorithms. Please review. I missed the guideline of 1 PR per algorithm, I'll keep it in mind for the future.

navkiran avatar Mar 14 '20 07:03 navkiran

Hi all, I want to contribute the jump search algorithm:

function found_at = jump_search(arr, value)
  % Contributed by   - Harshit Pant, [email protected]
  
  % arr       - The input array, should be sorted in ascending order.
  %             'arr' can contain -ve numbers as well as non-integers.
  % value     - The value to be searched in the array.
  % found_at  - The index at which 'value' is found in 'arr'.
  %             -1 is returned if 'value' is not found in 'arr'.

  n = length(arr);

  % 'm' holds the block size
  m = sqrt(n); 
  m = round(m); 
  low = 1;
  high = 1 + m;

  found_at = -1; 

  while arr(min(high, n)) < value
      low = high;
      high = high + m;
      if low >= n
          return;
      endif;
  endwhile;

  while arr(low) < value
      low = low + 1;
      if low > min(high, n)
          return;
      endif;
  endwhile;

  if arr(low) == value
      found_at = low;
  endif;

endfunction;


% TEST: 
% Save this file to your local computer, then use the command:
% jump_search([-11.1, -3.3, -1.3, 0.1, 1.5, 3.5, 3.9, 5.5, 7.5, 9.6, 13.7, 21.3, 35.9], 7.5)
% This should return, ans = 9.
% TODO - Transfer this test when automated testing functionality is added to this repository.

Is anyone available to review? I'd like to send a PR. Thankyou. (/cc @cozek, @Panquesito7 @ayaankhan98)

harshitpant1 avatar Jul 09 '21 17:07 harshitpant1

Hi all, I want to contribute the jump search algorithm:

function found_at = jump_search(arr, value)
  % Contributed by   - Harshit Pant, [email protected]
  
  % arr       - The input array, should be sorted in ascending order.
  %             'arr' can contain -ve numbers as well as non-integers.
  % value     - The value to be searched in the array.
  % found_at  - The index at which 'value' is found in 'arr'.
  %             -1 is returned if 'value' is not found in 'arr'.

  n = length(arr);

  % 'm' holds the block size
  m = sqrt(n); 
  m = round(m); 
  low = 1;
  high = 1 + m;

  found_at = -1; 

  while arr(min(high, n)) < value
      low = high;
      high = high + m;
      if low >= n
          return;
      endif;
  endwhile;

  while arr(low) < value
      low = low + 1;
      if low > min(high, n)
          return;
      endif;
  endwhile;

  if arr(low) == value
      found_at = low;
  endif;

endfunction;


% TEST: 
% Save this file to your local computer, then use the command:
% jump_search([-11.1, -3.3, -1.3, 0.1, 1.5, 3.5, 3.9, 5.5, 7.5, 9.6, 13.7, 21.3, 35.9], 7.5)
% This should return, ans = 9.
% TODO - Transfer this test when automated testing functionality is added to this repository.

Is anyone available to review? I'd like to send a PR. Thankyou. (/cc @cozek, @Panquesito7 @ayaankhan98)

Make a proper PR, maintainers will review.

ayaankhan98 avatar Jul 09 '21 17:07 ayaankhan98

Ok, thanks.

harshitpant1 avatar Jul 09 '21 18:07 harshitpant1

I have created a PR. Would you please review and suggest if any changes are required Thank you

AstroDude01 avatar Oct 21 '21 01:10 AstroDude01