Skip to content

Commit 58d6389

Browse files
authored
Merge branch 'master' into master
2 parents 286f374 + 66bc83f commit 58d6389

File tree

14 files changed

+68
-148
lines changed

14 files changed

+68
-148
lines changed

.github/copilot-instructions.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
1+
# Copilot Instructions for TheAlgorithms/R
2+
3+
## General Guidelines
4+
5+
This repository contains implementations of various algorithms in R. All contributions should follow these guidelines to maintain code quality and consistency.
6+
7+
## Code Quality & Functionality
8+
9+
- Ensure that your code is functional and well-structured before submitting
10+
- The code should run without errors in an R environment and produce the expected output
11+
- Follow best practices for efficiency, readability, and maintainability
12+
- Use consistent and meaningful variable names (use `.` or `_` to separate words, e.g., `results.df` for a data frame)
13+
14+
## Adding New Algorithms
15+
16+
When adding a new algorithm:
17+
- **Verify that the algorithm is not already implemented** in the repository (including under a different name)
18+
- **Confirm that the proposed algorithm is a recognized computer-science algorithm**, not a problem-specific adaptation of a general technique (e.g., tuned for LeetCode or other competitive-programming problems)
19+
- Include a brief explanation of the algorithm in the file as comments
20+
- Add an example showcasing its usage (can be commented within the script)
21+
- **Update DIRECTORY.md** to include the new algorithm in the appropriate section
22+
23+
## Modifying Existing Algorithms
24+
25+
When modifying existing algorithms:
26+
- Clearly document the changes in your pull request description
27+
- Ensure that your modifications do not break existing functionality
28+
- If applicable, update or add test cases to validate your changes
29+
30+
## File Naming & Structure Conventions
31+
32+
- **All code file names must use lowercase `.r` extension** (not `.R`)
33+
- Ensure that filenames follow the existing directory structure and naming patterns
34+
- Files should be placed in the appropriate category directory (e.g., `sorting_algorithms/`, `graph_algorithms/`, `mathematics/`)
35+
36+
## Documentation & Comments
37+
38+
- Provide clear and concise documentation in the form of comments within the code
39+
- Add a brief docstring at the beginning of the script explaining:
40+
- What the algorithm does
41+
- The expected input and output
42+
- Any dependencies required
43+
44+
## Testing & Verification
45+
46+
Before submitting a pull request, verify that your code:
47+
- Runs correctly with different test cases
48+
- Does not produce unnecessary warnings or errors
49+
- If applicable, add a test file demonstrating the algorithm's correctness
50+
51+
## Pull Request Review Checklist
52+
153
When reviewing a pull request:
2-
- Verify that any added algorithms or data structures aren’t already implemented elsewhere in the repository (including under a different name).
3-
- Confirm that the proposed algorithm is a recognized computer-science algorithm, not a problem-specific adaptation of a general technique (e.g., tuned for LeetCode or other competitive-programming problems).
4-
- Check that the extension of all code file names is a lowercase r.
5-
- Check that DIRECTORY.md was updated correctly.
54+
- Verify that any added algorithms or data structures aren't already implemented elsewhere in the repository (including under a different name)
55+
- Confirm that the proposed algorithm is a recognized computer-science algorithm, not a problem-specific adaptation of a general technique (e.g., tuned for LeetCode or other competitive-programming problems)
56+
- Check that the extension of all code file names is a lowercase `.r`
57+
- Check that DIRECTORY.md was updated correctly
58+
- Verify that the code includes appropriate documentation and examples
59+
- Ensure that variable naming follows repository conventions

DIRECTORY.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
* [Decision Tree](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/decision_tree.r)
77
* [Gradient Boosting Algorithms](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/gradient_boosting_algorithms.r)
88
* [Knn](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/knn.r)
9-
* [Lasso](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/lasso.r)
109
* [Light Gbm](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/light_gbm.r)
10+
* [Logistic Regression](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/logistic_regression.r)
11+
* [Logistic Regression 2](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/logistic_regression_2.r)
1112
* [Naive Bayes](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/naive_bayes.r)
1213
* [Random Forest](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/random_forest.r)
1314
* [Svm](https://github.com/TheAlgorithms/R/blob/HEAD/classification_algorithms/svm.r)
@@ -51,8 +52,6 @@
5152
* [Depth First Search](https://github.com/TheAlgorithms/R/blob/HEAD/graph_algorithms/depth_first_search.r)
5253
* [Dijkstra Shortest Path](https://github.com/TheAlgorithms/R/blob/HEAD/graph_algorithms/dijkstra_shortest_path.r)
5354

54-
## [Levenshtein](https://github.com/TheAlgorithms/R/blob/HEAD//levenshtein.r)
55-
5655
## Mathematics
5756
* [Amicable Numbers](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/amicable_numbers.r)
5857
* [Armstrong Number](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/armstrong_number.r)
@@ -63,7 +62,6 @@
6362
* [Fibonacci](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/fibonacci.r)
6463
* [First N Fibonacci](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/first_n_fibonacci.r)
6564
* [Greatest Common Divisor](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/greatest_common_divisor.r)
66-
* [Hamming Distance](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/hamming_distance.r)
6765
* [Josephus Problem](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/josephus_problem.r)
6866
* [Least Common Multiple](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/least_common_multiple.r)
6967
* [Perfect Number](https://github.com/TheAlgorithms/R/blob/HEAD/mathematics/perfect_number.r)
@@ -80,13 +78,8 @@
8078

8179
## Regression Algorithms
8280
* [Ann](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/ann.r)
83-
* [Gradient Boosting Algorithms](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/gradient_boosting_algorithms.r)
84-
* [Knn](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/knn.r)
85-
* [Light Gbm](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/light_gbm.r)
8681
* [Linear Regression](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/linear_regression.r)
8782
* [Linearregressionrawr](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/linearregressionrawr.r)
88-
* [Logistic Regression](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/logistic_regression.r)
89-
* [Logistic Regression 2](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/logistic_regression_2.r)
9083
* [Multiple Linear Regression](https://github.com/TheAlgorithms/R/blob/HEAD/regression_algorithms/multiple_linear_regression.r)
9184

9285
## Searches
@@ -123,9 +116,11 @@
123116
## String Manipulation
124117
* [Burrows](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/burrows.r)
125118
* [Findpalindrome](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/findpalindrome.r)
119+
* [Hamming Distance](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/hamming_distance.r)
126120
* [Is.Anagram](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/is.anagram.r)
127121
* [Is.Lower](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/is.lower.r)
128122
* [Is.Uppercase](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/is.uppercase.r)
123+
* [Levenshtein](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/levenshtein.r)
129124
* [Longest.Palindromic.Subsequence](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/longest.palindromic.subsequence.r)
130125
* [Longest.Substring.No.Repeat](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/longest.substring.no.repeat.r)
131126
* [Manacher.Longest.Palindrome](https://github.com/TheAlgorithms/R/blob/HEAD/string_manipulation/manacher.longest.palindrome.r)

classification_algorithms/lasso.r

Lines changed: 0 additions & 25 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

documentation/longest_common_subsequence.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,12 @@
550550
cat("Standard algorithm: LCS length =", standard_result,
551551
"Time:", sprintf("%.6f", standard_time), "seconds\n")
552552
</code></pre>
553-
<pre><code>## Standard algorithm: LCS length = 59 Time: 0.050064 seconds
553+
<pre><code>## Standard algorithm: LCS length = 59 Time: 0.052980 seconds
554554
</code></pre>
555555
<pre><code class="language-r">cat(&quot;Optimized algorithm: LCS length =&quot;, optimized_result,
556556
&quot;Time:&quot;, sprintf(&quot;%.6f&quot;, optimized_time), &quot;seconds\n&quot;)
557557
</code></pre>
558-
<pre><code>## Optimized algorithm: LCS length = 59 Time: 0.046882 seconds
558+
<pre><code>## Optimized algorithm: LCS length = 59 Time: 0.049993 seconds
559559
</code></pre>
560560
<pre><code class="language-r">cat(&quot;Results match:&quot;, standard_result == optimized_result, &quot;\n\n&quot;)
561561
</code></pre>

documentation/longest_common_subsequence.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ cat("Standard algorithm: LCS length =", standard_result,
540540
```
541541

542542
```
543-
## Standard algorithm: LCS length = 59 Time: 0.050064 seconds
543+
## Standard algorithm: LCS length = 59 Time: 0.052980 seconds
544544
```
545545

546546
``` r
@@ -549,7 +549,7 @@ cat("Optimized algorithm: LCS length =", optimized_result,
549549
```
550550

551551
```
552-
## Optimized algorithm: LCS length = 59 Time: 0.046882 seconds
552+
## Optimized algorithm: LCS length = 59 Time: 0.049993 seconds
553553
```
554554

555555
``` r

documentation/longest_increasing_subsequence.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@
412412
</code></pre>
413413
<pre><code class="language-r">cat(&quot;Time taken:&quot;, sprintf(&quot;%.4f sec&quot;, opt_time), &quot;\n&quot;)
414414
</code></pre>
415-
<pre><code>## Time taken: 0.0148 sec
415+
<pre><code>## Time taken: 0.0189 sec
416416
</code></pre>
417417
<pre><code class="language-r"># Verify correctness with basic DP (smaller sample for time comparison)
418418
nums_small &lt;- nums_perf[1:100]

documentation/longest_increasing_subsequence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ cat("Time taken:", sprintf("%.4f sec", opt_time), "\n")
398398
```
399399

400400
```
401-
## Time taken: 0.0148 sec
401+
## Time taken: 0.0189 sec
402402
```
403403

404404
``` r

regression_algorithms/gradient_boosting_algorithms.r

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)