All Questions
Tagged with recursion javascript
104 questions
7
votes
1
answer
232
views
Find the longest "common sequence" in two lists
In short, the algorithm must find the longest sequence that joins together common sequences from two lists (a more formal specification is given in the code's header).
The lists are assumed to contain ...
7
votes
1
answer
767
views
Get all partitions of an array into k non-empty sub-arrays
I am writing a function that takes an array and an integer number and returns an array of all the partitions into subarrays (so an array of arrays of subarrays). The number of subarrays is exact the ...
0
votes
1
answer
148
views
Can I optimize my implementation of generating Fibonacci series using recursion?
My function accepts a number, which generates total Fibonacci numbers. I am using recursion.
Please follow the code below,
...
0
votes
1
answer
360
views
Asynchronous recursive function for generating a unique Id
The code below is my first purpose built asynchronous recursive function. It took me a while to figure out how to write the thing, and I would like a second opinion.
It's part of a project for The ...
2
votes
2
answers
205
views
Arithmetic progression using Recursion
take an array of two numbers who are not necessarily in order, and then add not just those numbers but any numbers in between. For example, [3,1] will be the same as 1+2+3 and not just 3+1.
...
1
vote
1
answer
448
views
Recursively unpacking a javascript object
I'm seeing a React course, we were studying fundamentals of javascript for a while. We saw how to access the content of an object and display it in console. My solution for the problem of displaying ...
1
vote
0
answers
372
views
Codewars: Path Finder
Task
You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). Return true if you can reach position [N-1, N-1] or false ...
1
vote
1
answer
4k
views
Recursively access deeply nested object
Problem Statement
I need to access a deeply nested object. I could've used a 3rd party util such as Lodash but insisted myself on writing a Vanilla JS solution with a recursive strategy.
Code
Can this ...
0
votes
1
answer
337
views
Recursive Palindrome in JavaScript
Would someone review this code, and confirm that it is indeed recursive? I'm learning computer science and going through different types of algorithms. Right now, I'm focusing on recursion want to ...
3
votes
2
answers
1k
views
Pretty print directory structure in a JSON recursively
I am trying to pretty print the directory structure defined in a JSON. I do have a solution using recursion but I'm looking for feedback on how this solution can be ...
3
votes
0
answers
242
views
A valid Sudoku Generator without backtracking in JavaScript
I am new to programming. I tried to write a valid Sudoku solver with backtracking, the performance is disappointing.
So, I tried to generate a valid Sudoku generator without backtracking.
The white ...
2
votes
1
answer
374
views
Recursive function with Promise and setTimeout to ping DOM
I use this function in browser automation. It pings the document in the browser to check if an element we are looking for is available (useful when there is JavaScript generated async content). If it'...
2
votes
1
answer
531
views
JavaScript Sudoku Recursive Solver
Thanks for all the great feedback in Part 1. I implemented a lot of it. Here is version 2. I am looking for feedback on:
Recursive solve algorithm. It's too slow. I used Chrome DevTools Performance ...
2
votes
1
answer
64
views
recursive function improvement
I am creating routes from an array of menuItems. I have written a recursive function, which works fine but I think the code can be improved. So, I need you guys to review my code and suggest me some ...
1
vote
1
answer
62
views
Don't include root directory in HTML tree
I've written a function to create an HTML tree from JSON.
...