Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
0 answers
380 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 ...
Михаил Спирин's user avatar
1 vote
1 answer
104 views

Depth First Search vs Breadth First Search

So after years of teaching myself, I think I'm ready to stand on the shoulders of giants and ask you a good question! I have a tree of nodes. What I want is a function that returns an array of the ...
aName's user avatar
  • 143
5 votes
0 answers
227 views

A generic DFS in JavaScript

I implemented a general function for a depth-first-search (DFS) using JavaScript with default arguments and functions that need to be provided in order for it to work. This function is using ...
Evgeny Zislis's user avatar
3 votes
1 answer
2k views

Maze path finder using Depth-First Search algorithm

I'm trying to resolve this kata from CodeWars. Kata exercise 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). ...
Ender Look's user avatar
3 votes
1 answer
60 views

Javascript Tree Class 2

This question is the second version of the code here. I'm writing a general tree class. Specifically, each node should have oen parent, some number of children, and hold a value. I'm looking for ...
Alex F's user avatar
  • 443
4 votes
2 answers
1k views

Javascript Tree Class

I got caught in the trap of implementing my own data structure. I've created a very general tree structure, where each node gets one parent, some children, and holds a value. I'm mostly looking for ...
Alex F's user avatar
  • 443
1 vote
1 answer
1k views

Count number of islands 2d grid

This is a recursive approach using DFS to counting the number of islands. However, I would like to improve performance, while keeping the code clean concise and readable. Better yet can this be solved ...
Rick's user avatar
  • 586
1 vote
1 answer
882 views

Depth First Search (Adjacency List) in JavaScript

I am trying to implement a DFS search and graphs. How can I make it better? ...
Rohit Katyal's user avatar
2 votes
1 answer
469 views

Get all combination of a nested object with arbitrary levels

I have a JSON data which can be an object/array of recursively nested object or array. The value of an array can not be null, but an value in a object can be null. I would like to return all ...
Mike Lee's user avatar
  • 165
4 votes
1 answer
4k views

Get all combination of a nested object

I have JSON data which can be an object/array of recursively nested object or array. The value of an array can not be null, but a value in an object can be null. And I would like to return all ...
Mike Lee's user avatar
  • 165
1 vote
2 answers
2k views

Get a nested property of a complex object at any level of depth

Given a complex object (with nested objects at any depth) I need to be able to quickly retrieve a value for a given property name. I have designed the following ...
GibboK's user avatar
  • 667
5 votes
1 answer
2k views

Recursive, depth first search

I wanted to write a function findDeep that would perform a recursive, depth-first search on plain objects and arrays. Comments and criticism welcome. ...
52d6c6af's user avatar
  • 672
3 votes
0 answers
4k views

Depth first search implementation

I've been practicing my algorithms using The Algorithm Design Manual. I've decided to implement the depth first search section (5.8) using javascript. Note you can execute the code here if you don't ...
Daniel Jacobson's user avatar