All Questions
13 questions
2
votes
1
answer
273
views
Turn an array of pairs of start and end points into an ordered series
Given an array of pairs, for example:
[["Denver", "Miami"], ["Miami", "Tulsa"], ["LA", "Okmulgee"], ["Mobile", "Portland"...
1
vote
1
answer
524
views
Cheapest flights within k stops algorithm in JavaScript
The problem:
There are n cities connected by some number of flights. You are given
an array flights where flights[i] = [fromi, toi, pricei] indicates
that there is ...
8
votes
5
answers
296
views
Sort a list of pairs representing an acyclic, partial automorphism
I have this sample data:
let trips = [
{
from: "DEN",
to: "JFK"
},
{
from: "SEA",
to: "DEN"
},
{
from: 'JFK',
to: 'SEA'
},
];
...
0
votes
1
answer
651
views
Cracking the Coding Interview - 4.1 Graph Traversal
I'm working through the classic Cracking the Coding Interview book. I'm trying to solve the following graph problem:
4.1) Route Between Nodes: Given a directed graph, design an algorithm to find ...
3
votes
2
answers
2k
views
Dijkstra's algorithm in JavaScript
I'm trying to implement Dijkstra's algorithm to find the shortest path. This is from a challenge on CodeWars.
In this scenario there is a map:
...
5
votes
0
answers
180
views
Assembling and traversing a graph, given a list of items and parent pointers
I've written a function which takes input such as this:
...
8
votes
1
answer
4k
views
Cyclic "dependency detection" in JavaScript
I have written some simple code to detect cyclic dependencies for a module loading system and I'd like some feedback on how I can go about improving it. The code itself finds the first cycle in the ...
3
votes
0
answers
3k
views
Implementation of Dijkstra's Algorithm in JavaScript that returns both shortestDist/shortestPaths
I decided to try to understand the basic idea behind Dijkstra's algorithm better so I implemented it in JavaScript (the only language I am proficient in as of now) so I could really see what was ...
3
votes
2
answers
203
views
Vertex cover approximation in JavaScript
I believe this runs in \$O(V+E)\$ but I wouldn't be able to explain the reasons why. I was looking for some general code review and any help on understanding the runtime.
...
2
votes
0
answers
312
views
Return the Euler Cycle for a graph with es6
My algorithm for finding an Euler tour of a digraph, G⃗, if such a tour exists, starting from some vertex, v.
...
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 ...
3
votes
1
answer
59
views
Find order to install dependencies
Given a JavaScript map object of dependencies and their dependencies,
determine order to install them:
Example:
Input:
...
2
votes
1
answer
334
views