Skip to content

Commit fb5530f

Browse files
committed
fixing JSDOCS for some files in Recursive folder
1 parent 8d5cc4b commit fb5530f

5 files changed

+39
-4
lines changed

Diff for: Recursive/KochSnowflake.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@
1313
* https://natureofcode.com/book/chapter-8-fractals/ #84-the-koch-curve-and-the-arraylist-technique).
1414
*/
1515

16-
/** Class to handle the vector calculations. */
16+
/** Class to handle the vector calculations.
17+
* @class Vector2
18+
*/
1719
export class Vector2 {
20+
/**
21+
* Creates a new Vector2 instance.
22+
* @constructor
23+
* @param {number} x - The x component of the vector.
24+
* @param {number} y - The y component of the vector.
25+
*/
26+
1827
constructor(x, y) {
1928
this.x = x
2029
this.y = y

Diff for: Recursive/LetterCombination.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* More info: https://leetcode.com/problems/letter-combinations-of-a-phone-number/
1212
*/
1313

14-
/*
14+
/**
1515
* @param {string} digits
1616
* @returns {string[]} all the possible combinations
1717
*/

Diff for: Recursive/PalindromePartitioning.js

+11
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ import { palindrome } from './Palindrome'
55
* A palindrome partitioning partitions a string into palindromic substrings.
66
* @see https://www.cs.columbia.edu/~sedwards/classes/2021/4995-fall/proposals/Palindrome.pdf
77
*/
8+
/**
9+
* Returns all possible palindrome partitionings of a given string.
10+
* @param {string} s
11+
* @returns {string[][]} - Array of arrays containing all possible palindrome partitionings.
12+
*/
813
const partitionPalindrome = (s) => {
914
const result = []
1015
backtrack(s, [], result)
1116
return result
1217
}
1318

19+
/**
20+
* Backtracking function to find palindrome partitionings.
21+
* @param {string} s - The remaining part of the string to be checked for partitioning.
22+
* @param {string[]} path - Current partitioning path.
23+
* @param {string[][]} result - Array to store all valid palindrome partitionings.
24+
*/
1425
const backtrack = (s, path, result) => {
1526
if (s.length === 0) {
1627
result.push([...path])

Diff for: Recursive/SubsequenceRecursive.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
* https://en.wikipedia.org/wiki/Subsequence
1919
* https://en.wikipedia.org/wiki/Lexicographic_order
2020
*/
21-
21+
/**
22+
* Find all distinct, non-empty subsequences of a given string in lexicographical order using a recursive approach.
23+
* @param {string} str
24+
* @param {string} seq
25+
* @param {number} low
26+
* @param {string[]} [output=[]]
27+
* @returns {string[]}
28+
*/
2229
export const subsequence = (str, seq, low, output = []) => {
2330
if (low <= str.length && str.length !== 0) {
2431
output.push(seq)

Diff for: Recursive/TowerOfHanoi.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
// wiki - https://en.wikipedia.org/wiki/Tower_of_Hanoi
22
// Recursive Javascript function to solve tower of hanoi
3-
3+
/**
4+
* Solves the Tower of Hanoi problem recursively.
5+
* @param {number} n - The number of disks to move.
6+
* @param {string} from - The rod from which to move the disks.
7+
* @param {string} to - The rod to which to move the disks.
8+
* @param {string} aux - The auxiliary rod for moving disks.
9+
* @param {string[]} [output=[]] - Optional array to store the sequence of moves.
10+
* @returns {string[]} The sequence of moves to solve the Tower of Hanoi problem.
11+
*/
412
export function TowerOfHanoi(n, from, to, aux, output = []) {
513
if (n === 1) {
614
output.push(`Move disk 1 from rod ${from} to rod ${to}`)

0 commit comments

Comments
 (0)